Skip to main content

Insert text into pdf templates

Project description

Source Code: https://github.com/diafygi/pdfformfiller

Documentation: https://pdfformfiller.readthedocs.org/

This is a library that lets you easy insert text into a pdf. It is super useful when you need to prefill an existing pdf template (for example, a grant application form) with your own data.

pip install pdfformfiller

Once installed, you can add text fields to any pdf. You specify the bounding box of the field, and the text will auto-resize to fit within that rectangle.

from pdfformfiller import PdfFormFiller
filler = PdfFormFiller("myform.pdf")
filler.add_text(text, pagenum, (x1, y1), (x2, y2))
filler.write(outfile)

In order to determine the correct (x1, y1), (x2, y2) coordinates for your test field bounding box, we recommend dumping your existing pdf template to images with 72 dpi and using an image editor (like GIMP) to find the pixel coordinates of the rectangle you want your bounding box to be.

pdftoppm -png -r 72 myform.pdf myform-pages

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

PdfFormFiller-0.4.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file PdfFormFiller-0.4.tar.gz.

File metadata

  • Download URL: PdfFormFiller-0.4.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for PdfFormFiller-0.4.tar.gz
Algorithm Hash digest
SHA256 d0da7e3abee4144035e68de3baadf8ba1edf243f064f63f449abd3a8394c75d3
MD5 e79ade171bf43c0e2c787c153c854a64
BLAKE2b-256 5c6d3a2f5d9d0f65130075c778d0f88e6cfdeef432fe864f2c1fb41423279dc5

See more details on using hashes here.

Supported by

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