Skip to main content

The Python library for PDF forms.

Project description

PyPDFForm

PyPDFForm is a pure Python library for PDF form processing. It allows filling a PDF form programmatically by creating a Python dictionary with keys matching its annotated names for elements like text fields and checkboxes. It also supports other functionalities such as drawing image and merging multiple PDFs together.

Installing

Install using pip:

pip install PyPDFForm

Quick Example

A sample PDF form can be found here. Download it and try:

import os

from PyPDFForm import PyPDFForm2

PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM = os.path.join(
    os.path.expanduser("~/Downloads"), "sample_template.pdf"
)  # Change this to where you downloaded the sample PDF form

PATH_TO_FILLED_PDF_FORM = os.path.join(
    os.path.expanduser("~"), "output.pdf"
)  # Change this to where you wish to put your filled PDF form

with open(PATH_TO_FILLED_PDF_FORM, "wb+") as output:
    output.write(
        PyPDFForm2(PATH_TO_DOWNLOADED_SAMPLE_PDF_FORM)
        .fill(
            {
                "test": "test_1",
                "check": True,
                "test_2": "test_2",
                "check_2": False,
                "test_3": "test_3",
                "check_3": True,
            },
        )
        .read()
    )

After running the above code snippet you can find output.pdf at the location you specified, and it should look like this.

Documentation

PyPDFForm vs PyPDFForm2

PyPDFForm provides additional functionalities like editable support for PDF forms created using Adobe Acrobat or Sejda.

PyPDFForm2 supports PDF forms made by a wider range of tools, while discarding some of those additional functionalities.

It is strongly advised that you use PyPDFForm2 since only minimum supports will be made to PyPDFForm from now on.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

PyPDFForm-1.0.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyPDFForm-1.0.1-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file PyPDFForm-1.0.1.tar.gz.

File metadata

  • Download URL: PyPDFForm-1.0.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for PyPDFForm-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3a8d56d9db07efbc97aa0590eb9a079180550567eeeddd1565223f115327d47e
MD5 ee6faf5580ddaca511921f39c0ab6daa
BLAKE2b-256 5c3c044f003850e0986ac1e974e64ee9718e3384be20334054a31fa0a95553e1

See more details on using hashes here.

File details

Details for the file PyPDFForm-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: PyPDFForm-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for PyPDFForm-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0914164d60056a8074e2eceff3865de91fb26e7cdeef3b1c6fe270977fd529d2
MD5 05aaef888623ce8178253a62d2598e78
BLAKE2b-256 2662d1c410e7e9ce28700a716aa9a203bb4117040b6b8865a392b1caf2137c29

See more details on using hashes here.

Supported by

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