本文介绍了用PHP填写PDF表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有PHP库可用于填写PDF表单,然后将其保存(展平)为PDF文件?

Are there PHP libraries which can be used to fill PDF forms and then save (flatten) them to PDF files?

推荐答案

此处提到的库和框架都不错,但是如果您只想填写表格并将其展平,我建议您使用名为pdftk的命令行工具(PDF工具包).

The libraries and frameworks mentioned here are good, but if all you want to do is fill in a form and flatten it, I recommend the command line tool called pdftk (PDF Toolkit).

请参见 https://www.pdflabs.com/tools/pdftk- -pdf-toolkit/

您可以从php调用命令行,命令是

You can call the command line from php, and the command is

pdftk formfile.pdf fill_form fieldinfo.fdf output outputfile.pdf flatten

您将需要找到FDF文件的格式才能生成填充字段的信息.这是一个很好的链接:

You will need to find the format of an FDF file in order to generate the info to fill in the fields. Here's a good link for that:

http://www.tgreer.com/fdfServe.html

pdftk命令可以从PDF表单文件生成FDF文件.然后,您可以将生成的FDF文件用作示例.表单字段是FDF文件中看起来像这样的部分

The pdftk command can generate an FDF file from a PDF form file. You can then use the generated FDF file as a sample. The form fields are the portion of the FDF file that looks like

...
<< /T(f1-1) /V(text of field) >>
<< /T(f1-2) /V(text of another field) >>
...

您还可以查看 php-pdftk ,这是特定于PHP的库.我没有使用过,但是评论员Álvaro(如下)推荐它.

You might also check out php-pdftk, which is a library specific to PHP. I have not used it, but commenter Álvaro (below) recommends it.

这篇关于用PHP填写PDF表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 08:16