Skip to main content

pdf-form-tools

pdf-form-tools is an import-only Python package for filling layout-sensitive scanned PDF forms with deterministic placement helpers, a validated JSON recipe renderer, and visual verification primitives.

It is intentionally small:

  • render PDF pages to raster images
  • detect writable regions, checkbox boxes, lines, and guided text slots
  • draw text, checks, and circle selections onto an overlay
  • place caller-prepared images in nearby low-occupancy space without resizing
  • validate and render self-contained JSON form recipes
  • merge the overlay back into the original PDF

Install

python -m pip install pdf-form-tools

Supported Python versions: 3.11 through 3.14.

Example

from pathlib import Path

from pdf_form_tools import merge_overlay_pdf, render_form_recipe

recipe = {
    "schema": "pdf-form-tools.form-recipe.v2",
    "template": {"id": "example", "version": 1},
    "render": {
        "page_index": 0,
        "scale": 2,
        "expected_size": [1191, 1684],
    },
    "fields": {
        "name": {
            "value": "Emily",
            "rect": [300, 500, 500, 60],
            "align": "center",
            "max_size": 44,
            "min_size": 28,
        }
    },
    "circles": {
        "selected_item": {
            "rect": [650, 700, 48, 48],
            "stroke_width": 4,
        }
    },
}

source_pdf = Path("form.pdf")
overlay_png = Path("overlay-page1.png")
render_form_recipe(
    source_pdf,
    recipe,
    source_render_path=Path("preview-page1.png"),
    overlay_path=overlay_png,
)

merge_overlay_pdf(source_pdf, overlay_png, Path("form-filled.pdf"))

Workflow callers can place an already-prepared image without exposing their asset or sizing policy to the package:

from pdf_form_tools import Rect, place_image_near_rect

placed = place_image_near_rect(
    prepared_image,
    Rect(300, 900, 420, 8),
    transparent_overlay,
    prior_image_bounds,
    occupancy_image=rendered_page,
)

The helper preserves the supplied image size, searches a bounded area near the anchor, penalizes ordinary occupied pixels, and never overlaps protected regions.

Development

python -m pip install -e ".[dev]"
python scripts/validate_repository.py --build-dir "$BUILD_DIR" --evidence-file "$EVIDENCE_FILE"

See CONTRIBUTING.md for validation path requirements and the release flow.

Scope

This package owns reusable placement and generic recipe rendering. Template geometry, resolved values, profile bindings, and workflow policy remain declarative data or project-local runner concerns.

Metadata

Release files for pdf-form-tools 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdf-form-tools 3.0.0
File Size Uploaded
pdf_form_tools-3.0.0.tar.gz 18.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdf-form-tools 3.0.0
File Interpreter ABI Platform
pdf_form_tools-3.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.5 kB

Release files / pdf_form_tools-3.0.0.tar.gz

Download URL pdf_form_tools-3.0.0.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
061287e85f2ce2f2db2cb822dc94f53eefef3e67cca18b58f8c1d5233271a3d6
BLAKE2b-256 checksum
How to use checksums
0c9e7075be9bc16997c290449dd243a3497fc01d983a3e45f6b77201de7fedd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Release files / pdf_form_tools-3.0.0-py3-none-any.whl

Download URL pdf_form_tools-3.0.0-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
634b2f2974d9cfda5fba73e10278a80ee5e4d84365ea57407c4373e71b2ababa
BLAKE2b-256 checksum
How to use checksums
a9b92c8516b6dfeaba3e979ff5087d94df88baddeb7cf136b5d0932b57da83f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 12, 2026.

Transparency log

Release history Release notifications | RSS feed

3.0.4

2 release files

3.0.3

2 release files

3.0.2

2 release files

3.0.1

2 release files

This release

3.0.0 This release

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page