操作 PDF 文件并使用 Adob​​e 表单字段

发布于 2024-10-04 19:42:56 字数 934 浏览 1 评论 0原文

我已经通过堆栈溢出进行了搜索以回答类似的问题。

我目前有一个预制的 PDF,我已经使用 Adob​​e Acrobat PRO 在 PDF 中创建了一些输入字段。

完成整个表单后,我想使用 PHP 运行 PDF,使用数据库中的相关信息填写表单,然后重新保存 PDF。

目前,我正在使用 X,Y 值系统并使用 ZEND_PDF 来实现这一点,效果很好,但当我尝试创建复杂的 PDF 时,效率会下降。我认为首先在 PDF 中创建表单将是一种更有效的方法。

我读过有关使用 FDF 作为可能的解决方案的信息,但不确定这是否是最佳路线。 在 Acrobat 中创建字段后,保存它,然后转到“表格”->“表格”。导出表格数据为 -> FDF 或 XML

但如果我在记事本中打开它,我在文件中的响应如下:

%FDF-1.2
%âãÏÓ
1 0 obj
<</FDF<</F(this-is-my-pdf-pro.pdf)/Fields[<</T(contractType)/V/Off>>]/ID[<545A7F611C15BEFE4DFE4C7C829256AE><60AD70B6B530BF42B5F2D52956886AA7>]/UF(this-is-my-pdf-pro.pdf)>>/Type/Catalog>>
endobj
trailer
<</Root 1 0 R>>
%%EOF

除了 1 RADIO 选择选项之外,我似乎没有看到任何对字段的引用...我在那里有文本字段也一样,但不显示。 所以我的问题归结为,最好的解决方案是什么?

  1. 继续使用 X,Y 坐标填写我的 PDF,
  2. 使用 Adob​​e Acrobat 创建字段并运行搜索和替换或其他操作?

如果有人有任何解决方案,我将不胜感激!

I have searched through stack-overflow in response to a similar question.

I currently have a pre-made PDF, which I have gone and used Adobe Acrobat PRO to create some entry fields within the PDF.

Once I have completed the entire form, I would like to use PHP to run through the PDF fill in the form with the associated information from a database, and re-save the PDF.

Currently I am using an X,Y value system and using ZEND_PDF to make that happen, which works great, but effeciency is down the tubes when i'm trying to create a complex PDF. And I think creating the form within the PDF first would be a much more effecient way of doing it.

I have read about using FDF as a possible solution, but not sure if this is a the best route.
After I created the fields in Acrobat, I save it, and go to FORMS -> EXPORT FORM DATA AS -> FDF or XML

But my response in the file is as follows if i open it in notepad:

%FDF-1.2
%âãÏÓ
1 0 obj
<</FDF<</F(this-is-my-pdf-pro.pdf)/Fields[<</T(contractType)/V/Off>>]/ID[<545A7F611C15BEFE4DFE4C7C829256AE><60AD70B6B530BF42B5F2D52956886AA7>]/UF(this-is-my-pdf-pro.pdf)>>/Type/Catalog>>
endobj
trailer
<</Root 1 0 R>>
%%EOF

And I don't seem to see any reference to fields at all other than the 1 RADIO selection option... I have text-fields in there as well but not being displayed.
So my question comes down to, what is the best solution for this?

  1. Continue using X,Y coordinates to fill in my PDF
  2. using Adobe Acrobat to create the fields and run a search and replace or something?

If anyone has any solutions I would be much appreciative!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

維他命╮ 2024-10-11 19:42:56

我已成功使用 PDFlib 来填写“模板”PDF。它有一个“块”系统,您可以在 PDF 上“绘制”块,并在运行时通过简单地指定“用内容 Y 填充块 X”以编程方式填充它们 - 有图像、文本和 PDF 块类型。图像几乎可以是任何类型,文本可以包含任意伪 html 和 PDF 特定类型的格式字符串。 PDF 块仅允许您在块中嵌入另一个 PDF。

缺点是 PDFlib 的许可费用相当昂贵。

I've used PDFlib successfully to fill in "template" PDFs. It has a "blocks" system, where you can 'draw' blocks on a PDF, and programmatically fill them in at run-time by simply specifying "fill Block X with content Y" - there's image, text, and PDF block types. Images can be of pretty much any type, the text can contain arbitrary pseudo-html and PDF-specific type formatting strings. The PDF block just allows you to embed another PDF within the block.

The drawback is that PDFlib is pretty pricey to license.

海未深 2024-10-11 19:42:56

PDFtk 应该可以帮助您从现有 PDF 文档中提取字段并
然后用实际值填充 PDF。但奇怪的是,Acrobat 无法正确提取字段,因此您在创建字段时可能做错了什么(我不了解 Acrobat,因此无法提供帮助)。

无论如何,您可以检查 PDFtk 找到了哪些字段,如下所示:

pdftk form.pdf dump_data_fields

然后填写如下表格:

pdftk form.pdf fill_form field-values.fdf output form-out.pdf

PHP has tools to create FDF 文件

PDFtk should help you extract the fields from an existing PDF document and
then fill the PDF with actual values. But it is strange that Acrobat doesn't extract the fields correctly, so you may have done something wrong when creating the fields (I don't know Acrobat so can't help in this).

Anyway, you may check which fields PDFtk finds like this:

pdftk form.pdf dump_data_fields

and then fill in the form like this:

pdftk form.pdf fill_form field-values.fdf output form-out.pdf

PHP has tools to create FDF files.

云归处 2024-10-11 19:42:56

我能够使用 WKHTMLTOPDF 作为管理我的一些字段和信息的途径。

http://wkhtmltopdf.org/

I was able to use WKHTMLTOPDF as a route to manage some of my fields and information.

http://wkhtmltopdf.org/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文