Skip to main content

The Python library for PDF forms.

Project description

Important API Changes

Happy new year fellow developers! We start the year 2024 with a new release of v1.4.0 and there are some important changes I'm making to the APIs of the library.

  • The PDF object that gets instantiated is now PyPDFForm.PdfWrapper, changed from PyPDFForm.PyPDFForm.
  • Form widgets are now accessed via the PdfWrapper.widgets attribute, changed from PdfWrapper.elements.
  • The JSON schema of the form data is now accessed via a new attribute called PdfWrapper.schema, changed from the old method of PdfWrapper.generate_schema().

All the old APIs will be persisted for half a year and then fully deprecated. Each of them will emit a DeprecationWarning when invoked, so it is advised that you make the switch before they are removed and start breaking your code.

Happy hacking!

Introduction

PyPDFForm is a free and open source pure-Python 3 library for PDF form processing. It contains the essential functionalities needed to interact with PDF forms:

  • Inspect what data a PDF form needs to be filled with.
  • Fill a PDF form by simply creating a Python dictionary.
  • Create a subset of form widgets on a PDF.

It also supports other common utilities such as extracting pages and merging multiple PDFs together.

Installing

Install using pip:

pip install PyPDFForm

Quick Example

Check out the GitHub repository for a live demo if you can't see it here.

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

from PyPDFForm import PdfWrapper

filled = PdfWrapper("sample_template.pdf").fill(
    {
        "test": "test_1",
        "check": True,
        "test_2": "test_2",
        "check_2": False,
        "test_3": "test_3",
        "check_3": True,
    },
)

with open("output.pdf", "wb+") as output:
    output.write(filled.read())

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

Documentation

The official documentation can be found on the GitHub page of this repository.

Public Speak

Chicago Python User Group - Dec 14, 2023

How to Contribute

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

This version

1.4.7

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.4.7.tar.gz (23.4 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.4.7-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for PyPDFForm-1.4.7.tar.gz
Algorithm Hash digest
SHA256 81fec57ff0e591aa427c7f00ec9a2a1129e5379d4cdc031b3e34a90ebe6e0847
MD5 6bdc63db5e66e162915989f38ac7f1c4
BLAKE2b-256 1b90ce842e3acf51c2e94ec17db79c3d7184982127d1925b438df8501773dc3f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for PyPDFForm-1.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ba53b6ce126efbb0d86ba658d35687b50c6b78cb98bc68eac2a3e09febd27c6f
MD5 f7de68e8eeeb2a72084738483a8fd384
BLAKE2b-256 2caa438c6d07a42b929f82dff5fd6c9ad09a3c41cfd55b6ac233816fe7544735

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