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.

How to Contribute

If you wish to improve this library, there is one specific way you can contribute on top of the usual open source project norms such as issues and pull requests.

It is difficult to make sure that the library supports all the PDF form creating tools out there. So if you run into a case where the library does not work for certain PDF forms created by certain tools, feel free to open an issue with the problematic PDF form attached. I will seek to make the library support the attached PDF form as well as the tool used to create it.

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.1.4.tar.gz (16.3 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.1.4-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: PyPDFForm-1.1.4.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for PyPDFForm-1.1.4.tar.gz
Algorithm Hash digest
SHA256 bc7cd06cfd48134c4545566cf659a5047a6a54ab60f93b0775d4fa2193038c75
MD5 18145f8c0bb41ada724c6620760de32a
BLAKE2b-256 b7e7fb2a9e5e3c72c122f03ab0dd3ba8042a31e25043b51e3c77668567279a53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyPDFForm-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for PyPDFForm-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 66b1aa457cd0c63e86b9d105a565b1772f38284fbb9fee91542f3ad2c740415d
MD5 55ff03fb8beeb1e326f9a58ea5a20d29
BLAKE2b-256 b3de4359aa1b0bb3a243c6759acf18b2edf8a409ed944af47c9b208829d1c194

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