PHP PDF模板库具有PDF输出? [英] PHP PDF template library with PDF output?
问题描述
是否有任何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?
要求:
-
不需要第三方Web服务
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:
-
TCPDF只能从头开始生成文档
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 rep,必须是某种记录:)
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
这篇关于PHP PDF模板库具有PDF输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!