I am trying to build a small flask web app that displays a job application built from an HTML form with many fields for an applicant to fill out. I want to grab the inputted data from this HTML form, and use the data to fill out a "fillable PDF" that I made with Adobe Acrobat DC Pro. I am fairly new to python and attempted to complete this using PHP however libraries like pdftk were unable to run on the OS I was running. This library is pretty old which is why I am seeing if this task is doable using Pypdftk instead. I have yet to find any clear resources on how to use the pypdftk library to do something like this, maybe I haven't searched hard enough but I am running out of options and am honestly stumped. At the end of the day, I guess I just want to know if something like this is possible with python or any of the current libraries, doesn't have to be pypdftk. Thanks for any help and guidance in advance!!! Job Application
-
Hi, welcome to StackOverflow. Please review [ask] and provide a [mcve] when asking a question – admcfajn Jul 15 '20 at 22:02
-
@brandonchuck_ please mark my answer as correct if it was right and helped you solve your issue. – Kuldeep Aug 25 '20 at 17:56
2 Answers
You can use pdftk on Windows and Linux both. I have been using pdftk from sometime now. you can fill out a form using pdftk, you need to create an fdf file and then pdftk can use that fdf file to fill the pdf. To do that you need the following command:
pdftk mypdf.pdf generate_fdf output data.fdf
This command will then generate a data.fdf file which contains data like following
<<
/Fields [
<<
/V (Red)
/T (Favorite Color List Box)
>>
<<
/V ()
/T (Country Combo Box)
>>
<<
/V ()
/T (Given Name Text Box)
>>
You need to place your value within the brackets next to /V like this
/V (Kuldeep)
/T (Given Name Text Box)
Save the file and then you need to execute following command
pdftk mypdf.pdf fill_form data.fdf output form_filled.pdf
This will save the filled form pdf. form_filled.pdf is the filled out pdf.
You can save the generated fdf file as a template and and use it again and again programatically. You need to run these commands using python to make it work. And also check this pdftk manual.

- 489
- 6
- 10
-
-
@AbuzerFirdousi Are you asking how to create a pdf with an image inside it? – Kuldeep Jan 29 '21 at 12:45
-
We have a fillable PDF form with images. Need to replace the image fields with images. – Abuzer Firdousi Jan 30 '21 at 17:03
-
I have not used pdftk with images also I don't know how one can extract the images from images fields but take a look here https://askubuntu.com/a/150106 . this might help. – Kuldeep Feb 01 '21 at 14:37
According to pypdftk, filling forms is possible with this library, so it should basically work. You could use e.g. uWSGI to trigger the script.

- 698
- 7
- 17
-
Okay great! I am also getting this confusing error when installing pypdftk using pip3 install pypdftk: Collecting pypdftk ... ---------------------------------------- Failed building wheel for pypdftk Running setup.py clean for pypdftk Failed to build pypdftk Installing collected packages: pypdftk Running setup.py install for pypdftk ... done Successfully installed pypdftk-0.4 – brandonchuck_ Jul 18 '20 at 03:38