Skip to main content

Library wrapping pdftk to fill and sign PDFs

Project description

pdf_template

Small wrapper around pdftk for filling and signing PDFs

Example:

from pdf_template import PDFTemplate, PDFTemplateSection, SignatureBoundingBox
from PIL import Image

input_data = {
    "is_18_or_over": True,
    "title_mr": False,
    "title_ms": True,
    "first_name": "Foo",
    "last_name": "Bar",
    "address1": "None",
    "zipcode": None,
    "mailto_line_1": "some address!",
}

template = PDFTemplate(
    [
        PDFTemplateSection(path="tests/test-input-page-1.pdf", is_form=True),
        PDFTemplateSection(
            path="tests/test-input-page-2-3.pdf",
            is_form=True,
            signature_locations={
                1: SignatureBoundingBox(x=300, y=490, width=200, height=37)
            },
        ),
        PDFTemplateSection(
            path="tests/test-input-page-4.pdf",
            signature_locations={
                1: SignatureBoundingBox(x=188, y=50, width=200, height=28)
            },
        ),
    ]
)

with template.fill(
    input_data, signature=Image.open("tests/sig.jpeg")
) as output_pdf:
    with open("output.pdf", "wb") as out_file:
        out_file.write(output_pdf.read())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_template-0.0.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pdf_template-0.0.2-py2.py3-none-any.whl (7.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pdf_template-0.0.2.tar.gz.

File metadata

  • Download URL: pdf_template-0.0.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for pdf_template-0.0.2.tar.gz
Algorithm Hash digest
SHA256 7e108ffabdd99e126d8ec3914e19c45b79c38df383471231ecdf0e093b936ab3
MD5 83a22e26ab42cacf609ed0ab0358dc89
BLAKE2b-256 8fe750c71773d7f59a6c5f1e972999b246d5a41e3657c7d0a2a62e99dfbc4a2f

See more details on using hashes here.

File details

Details for the file pdf_template-0.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pdf_template-0.0.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

File hashes

Hashes for pdf_template-0.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 028913e0dbd394511b5a843f4dab8dfb971dd8a8193a711d7ebc722e62020c61
MD5 04ce7db416f3489d4ed313a94c28d945
BLAKE2b-256 f2c5e8c22c7b53c7c13b7389ce813639fc1680f60a89e48ee244267639c835ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page