带有PDF输出的PHP PDF模板库? [英] PHP PDF template library with PDF output?

查看:28
本文介绍了带有PDF输出的PHP PDF模板库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何 PHP PDF 库可以替换现有 PDF、ODT 或 DOCX 文档中的占位符变量,并生成 PDF 文件作为最终结果,而不会弄乱布局?

Is there any PHP PDF library that can replace placeholder variables in an existing PDF, ODT or DOCX document, and generate a PDF file as the end result, without screwing up the layout?

要求:

  • 不需要第三方网络服务

  • Needs no 3rd party web service

能够在共享虚拟主机上运行是理想的(不需要二进制安装/包)

Ability to run on shared web hosting would be ideal (no binary installations / packages required)

请注意,一个能够加载现有 PDF 文件并以编程方式在特定位置插入文本的库对于我的用例来说不够.

Mind you, a library that is able to load an existing PDF file and insert text programmatically at a specific position is not enough for my use case.

据我的研究表明,没有图书馆可以做到这一点:

As far as my research shows, there is no library that can do this:

  • TCPD 只能从头开始生成文档

  • TCPDF can only generate documents from scratch

FPDI 可以读取现有的 PDF 模板,但只能以编程方式添加内容(无模板变量替换)

FPDI can read existing PDF templates, but can only add contents programmatically (no template variable replacement)

有各种 DOCX/ODT 模板库,但它们不输出 PDF

There are various DOCX/ODT template libraries out there but they don't output PDF

PHPDOCx 声称能够完全满足我的需求 - 但他们不提供试用版,我也没有打算买一只装在袋子里的猫,尤其是当网络上似乎没有其他产品可以做到这一点时.我发现很难相信他们可以毫无问题地做到这一点 - 如果您使用该产品成功做到了这一点,请在此处留言.

PHPDOCx claims to be able to do exactly what I need - but they don't offer a trial version and I'm not going to buy a cat in a bag, especially not when there seems to be no other product on the web that does this. I find it hard to believe they can do this without problems - if you have successfully done this using the product, please drop a line here.

我是否忽略了什么?

有没有办法使用 PDF 表单来做到这一点?我正在 OpenOffice 3 中创建源文档.

Is there a way to do this using PDF forms? I am creating the source documents in OpenOffice 3.

我或许可以使用标准的 Linux 命令(例如,pdftk 可用,现在就尝试一下.)

I may be able to use standard Linux commands (pdftk is available for example, trying that out right now.)

更新: *啊!* 我被叫出办公室,赏金在此期间到期.开始新的赏金:就我的测试而言,目前还没有任何解决方案适合我.

Update: *Argh!* I was called out of the office and the bounty expired in the meantime. Starting a new bounty: As far as my testing shows, no solution works for me perfectly yet.

更新 II:我很快就会研究 pdftk 方法,但我也开始了另一轮赏金,以收集更多的额外输入.这个问题现在已经看到了 1300 代表点的赏金,一定是某种记录:)

Update II: I will be looking the pdftk approach soon, but I am also starting another bounty for one more round of collecting additional input. This question has now seen 1300 rep points in bounties, must be some kind of a record :)

推荐答案

Pekka,

我之前看过这个,我想你可以使用 pdftk(命令行实用程序),使用 FDF/XFDF 数据文件填写 PDF 表单,您可以在 PHP 中轻松生成这些文件.这是迄今为止我见过的最好的选择,尽管很可能有一个本地库.

I looked in to this previously, I think you can use pdftk (a command line utility), to fill in a PDF form using FDF/XFDF data files, which you could easily generate from within PHP. That was the best option I've seen so far, though there may well be a native library.

pdftk 总的来说还是很有用的,值得一看.

pdftk is quite useful in general, worth having a look at.

更新:看看这里:http://php.net/manual/en/book.fdf.php

这篇关于带有PDF输出的PHP PDF模板库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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