用 PHP 填写 PDF 表单 [英] Filling PDF Forms with PHP

查看:27
本文介绍了用 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-the-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 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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