2

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

2 Answers2

3

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.

Kuldeep
  • 489
  • 6
  • 10
0

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.

scenox
  • 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