Skip to main content

A Library to fill and flatten pdfs

Project description

fillpdf

https://pypi.org/project/fillpdf/

Overview

This is a simple package to make filling pdfs much easier. I have delt with a lot projects that involve manipulating pdfs in python. I found no easy solution for writting, or flattening pdfs, so I decided to make a library to make this task much easier. As a young software engineer I kept this library really simple but practicle and am open to any input for the future!

  • Fills pdfs
  • Lists fields in pdf
  • Flattens pdfs (Turns to a non-editable pdf)

Function Documentation

import fillpdf
from fillpdf import fillpdfs
get_form_fields (returns the data_dict)
get_form_fields(input_pdf_path)
  • input_pdf_path- path to your pdf you want to alter (including the pdf name could just leave as 'blank.pdf' if the pdf is in your current directory)
For Example:
fillpdfs.get_form_fields('blank.pdf')
print_form_fields (prints the data_dict)
print_form_fields(input_pdf_path)
  • input_pdf_path- path to your pdf you want to alter (including the pdf name could just leave as 'blank.pdf' if the pdf is in your current directory)
For Example:
fillpdfs.print_form_fields('blank.pdf')
write_fillable_pdf
write_fillable_pdf(input_pdf_path, output_pdf_path, data_dict, flatten=False)
  • input_pdf_path- path to your pdf you want to alter (including the pdf name could just leave as 'blank.pdf' if the pdf is in your current directory)
  • output_pdf_path- path of where you want your pdf to write to (including the pdf name could just leave as 'new.pdf' to write to current directory)
  • data_dict- dictionary that contains the fields to write to as your key and what to write to it as your value (get this from the get_form_fields function)
  • flatten (default=False)- If True, then the fields will become uneditable when you write to the pdf.
For Example:
data_dict = {'Address 1 Text Box': '500 West Main Street',
'Driving License Check Box': 'Yes',
'Language 1 Check Box': 'Off',}

fillpdfs.write_fillable_pdf('blank.pdf', 'new.pdf', data_dict)
  • For radio boxes ('Off' = not filled, 'Yes' = filled)
flatten_pdf
flatten_pdf(input_pdf_path, output_pdf_path, as_images=False)
  • input_pdf_path- path to your pdf you want to alter (including the pdf name could just leave as 'blank.pdf' if the pdf is in your current directory)
  • output_pdf_path- path of where you want your pdf to write to (including the pdf name could just leave as 'new.pdf' to write to current directory)
  • as_images=False- Default is False meaning it will update each individual annotation and set it to False. True means it will convert to images and then reinsert into the pdf. Try this if the first is not working. (this image technique requires poppler.)
For Example:
fillpdfs.flatten_pdf('new.pdf', 'newflat.pdf')

Software Demo Video

Installation

pip install fillpdf 
conda install -c conda-forge poppler

Development Environment

Builds upon
  • 'pdfrw'
  • 'pdf2image'
  • 'Pillow'
  • 'poppler'

Useful Websites

Credit

Future Work

  • Add perfect fill (sometimes does not fill random things ie. drop down lists)
  • give option to place text by coordinate
  • easier way to fill the data dictionary in write_fillable_pdf function
  • fill drop downs

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

fillpdf-0.3.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

fillpdf-0.3.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file fillpdf-0.3.2.tar.gz.

File metadata

  • Download URL: fillpdf-0.3.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.3

File hashes

Hashes for fillpdf-0.3.2.tar.gz
Algorithm Hash digest
SHA256 18a4440a4f5ded5b69a00c8810b16b7c93e7c808d33ea819b876618397caec63
MD5 82a4fe104b9627b09ad30617021c67de
BLAKE2b-256 8f92e1c6d85e21e51d0d01af0881589cbdf9657fe946ff20ffa276b3309b161f

See more details on using hashes here.

File details

Details for the file fillpdf-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: fillpdf-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.26.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.3

File hashes

Hashes for fillpdf-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b9aea112ae63b1ec65d07f1beddd777d256043e7f52241e6d023bca611d8098
MD5 c286e14526eab5dcca9d5275c14a30d3
BLAKE2b-256 b520425c97c41803b21ea148ce36162207614196f800fa2f0fab27b37fa9b8e5

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