Fill out “fillable pdf” with HTML form “post” data using python?

前端 未结 2 1418
名媛妹妹
名媛妹妹 2020-12-21 18:29

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

相关标签:
2条回答
  • 2020-12-21 19:25

    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.

    0 讨论(0)
  • 2020-12-21 19:32

    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.

    0 讨论(0)
提交回复
热议问题