Skip to content Skip to sidebar Skip to footer

Fill Out "fillable Pdf" With Html Form "post" Data Using Python?

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 f

Solution 1:

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.

Solution 2:

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.

Post a Comment for "Fill Out "fillable Pdf" With Html Form "post" Data Using Python?"