填写“可填充的pdf" HTML格式的"post"使用python的数据? [英] Fill out "fillable pdf" with HTML form "post" data using python?

查看:55
本文介绍了填写“可填充的pdf" HTML格式的"post"使用python的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个小型的Flask Web应用程序,该应用程序显示通过HTML表单构建的作业应用程序,其中包含许多字段供申请人填写. 我想从此HTML表单中获取输入的数据,并使用该数据填写可填充PDF" 我对python还是很陌生,并尝试使用PHP完成此操作,但是pdftk之类的库无法在我正在运行的OS上运行.这个库已经很老了,这就是为什么我看到使用Pypdftk这项任务是否可行的原因.对于如何使用pypdftk库执行类似的操作,我还没有找到任何明确的资源,也许我没有进行足够的搜索,但是我用尽了所有选项,并且感到很沮丧.归根结底,我想我只是想知道是否可以使用python或任何当前库来进行类似的操作,而不必是pypdftk.感谢您的任何帮助和事先的指导!!! 工作申请

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

推荐答案

您可以在Windows和Linux上同时使用pdftk.我从现在开始一直在使用pdftk.您可以使用pdftk填写表格,您需要创建一个fdf文件,然后pdftk可以使用该fdf文件来填充pdf.为此,您需要以下命令:

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

然后该命令将生成一个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)
>>

您需要像这样将值放在/V旁边的括号中

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

这将保存填写的表格pdf. form_filled.pdf是填写好的pdf.

This will save the filled form pdf. form_filled.pdf is the filled out pdf.

您可以将生成的fdf文件另存为模板,然后以编程方式一次又一次地使用它.您需要使用python运行这些命令以使其工作.还要查看 pdftk手册.

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.

这篇关于填写“可填充的pdf" HTML格式的"post"使用python的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆