Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/t-houssian/fillpdf into main
Browse files Browse the repository at this point in the history
  • Loading branch information
t-houssian committed Nov 26, 2021
2 parents e75b847 + 1955a20 commit 4483fb1
Showing 1 changed file with 65 additions and 4 deletions.
69 changes: 65 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ This is a simple package to make filling pdfs much easier. I have delt with a lo
'Language 1 Check Box': 'Off',}

fillpdfs.write_fillable_pdf('blank.pdf', 'new.pdf', data_dict)
- For radio boxes ('Off' = not filled, 'Yes' = filled)
- For radio boxes ('Off' = not filled, 'Yes' = filled)
- For check boxes ('Off' or '' = not filled, 'Yes' = filled)
- For drop downs (Enter the name of the desired drop down option)
- For radio groups ('0' = The first option, '1' = The second option, '2' = the third option, etc.)

##### flatten_pdf
flatten_pdf(input_pdf_path, output_pdf_path, as_images=False)
Expand All @@ -46,13 +49,68 @@ This is a simple package to make filling pdfs much easier. I have delt with a lo
pdf. Try this if the first is not working. (this image technique requires poppler.)
###### For Example:
fillpdfs.flatten_pdf('new.pdf', 'newflat.pdf')

# Command Line Use
A command line wrapper is available for this tool. Here are the two commands:
##### extractfillpdf
extractfillpdf input_pdf_path
or
extractfillpdf input_pdf_path -o output_json_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)
- output_json_path- path of where you want your json file containing the fields and contents of the pdf to write to (If not included then the default will be the same name/path as the input_pdf_path but .json instead of .pdf)
###### For Example:
extractfillpdf blank.pdf
or
extractfillpdf blank.pdf -o data.json
##### insertfillpdf
insertfillpdf -j input_json_path -o output_pdf_path 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)
- input_json_path- path to the json file that you generated and modified with the extractfillpdf command.
- 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)
###### For Example:
insertfillpdf -j blank.json -o new.pdf blank.pdf
###### Help Command
extractfillpdf --help or extractfillpdf -h
Will bring up this menu

positional arguments:
test.pdf Input pdf file

optional arguments:
-h, --help show this help message and exit
-o test.json, --output test.json
Output file to write result, if none given, it will be the input file
with the JSON extension
--version show program's version number and exit
-v, --verbose set loglevel to INFO
-vv, --very-verbose set loglevel to DEBUG
###### Or:
insertfillpdf --help or insertfillpdf -h
Will bring up this menu

positional arguments:
test.pdf Input PDF file

optional arguments:
-h, --help show this help message and exit
-j test.json, --JSON test.json
Input JSON file, if none given, it will be the input file with the JSON
extension
-o test_out.pdf, --output test_out.pdf
Output file to write result, if none given, it will be the input file
with '_out.pdf' extension'
--version show program's version number and exit
-v, --verbose set loglevel to INFO
-vv, --very-verbose set loglevel to DEBUG


[Software Demo Video](https://youtu.be/oM9XGmpbGyg)

# Installation
pip install fillpdf
conda install -c conda-forge poppler
poppler is only needed if you are using the as_images=True mode of the `flattenpdf` function

# Development Environment
##### Builds upon
Expand All @@ -67,15 +125,18 @@ This is a simple package to make filling pdfs much easier. I have delt with a lo
* [List PDF Fields](https://stackoverflow.com/questions/3984003/how-to-extract-pdf-fields-from-a-filled-out-form-in-python)
* [Fill PDF Fields](https://stackoverflow.com/questions/60082481/how-to-edit-checkboxes-and-save-changes-in-an-editable-pdf-using-the-python-pdfr)
* [Flatten PDFs](https://stackoverflow.com/questions/27023043/generate-flattened-pdf-with-python)
* [pdfrw2](https://pypi.org/project/pdfrw2/)

# Credit
- [dvska](https://stackoverflow.com/users/1303068/dvska)
- [gbroiles](https://github.com/pmaupin/pdfrw/issues/165)
- [tomatoeshift](https://stackoverflow.com/users/11998874/tomatoeshift)
- [Tyler Houssian](https://stackoverflow.com/users/13537359/tyler-houssian)
- [jtplaarj](https://github.com/jtplaarj)
- [WestHealth](https://github.com/WestHealth/pdf-form-filler)
- [sarnold](https://github.com/sarnold)
- [Patrick Maupin](https://github.com/pmaupin)

# 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
* alter or view pdf versions

0 comments on commit 4483fb1

Please sign in to comment.