问题描述
我们有一个高分辨率PDF(用于打印),其上有一些表单域。我们希望有一个提交给PDF的HTML表单,然后将其放到各个字段中。
我在google上找到了一个解决方案:
但是,使用该解决方案,您只能获得一个FDF文件...并且该演示对我无效,打开FDF文件只需下载另一个FDF文件。
由于此PDF将公开发布,因此我们希望尽可能简单。如果我们必须打开我们的原始PDF文件并导入这个FDF文件,我们需要一个不同的解决方案(我不确定是FDF文件的用途,因为它不起作用)。
有关.net框架的相关文章有相同的想法,但只有付费的商业解决方案:
到目前为止,我发现的PHP解决方案都是为了创建一个新的PDF,这不是我所需要的。我们的PDF是使用Adobe Illustrator(或类似的adobe产品)创建的,并且是嵌入式字体,svg和图像内容的高分辨率。
表单元素已经到位,我们只需要将数据提交到那里。
更新2013年4月11日:
自发布此问题以来,我一直在利用我需要完成这个目标的多个项目。尽管它似乎无法将模板PDF与提供的数据合并,但它可以从头开始创建PDF。
我用过的一个例子是,我有一个高分辨率的PNG打印(类似于最初的问题),我们必须在客户的中心清楚地写下客户的姓名和当天的日期。我只是使用制作了PDF的背景,之后使用。
毕竟,您需要查看纸张大小以确定图像的X,Y,W,H,然后将文本字段与这些数字相关联。
甚至还有,但我无法使其正常工作。
似乎我应该回答自己的问题,虽然Visions的答案可能会更好(似乎会被删除?)。我使用了Vasiliy Faronov的链接,这个链接是我对主要问题的评论:并运行一个命令来合并(拼合)我的FDF和PDF文件。我仍然使用hacky方式使用生成FDF,但是它的作用大部分。
一个警告是一些字符,如单引号和双引号没有正确插入。这可能是一个逃避领域的问题,但我找不到答案。
无论如何,我的PDF表单生成器是正常工作,但任何有类似问题的人都应该寻找更好的解决方案。
We have a high-resolution PDF (for printing) which has some form fields on it. We would like to have an HTML form which submits to the PDF, which is then placed into the respective fields.
I found a solution on google: http://koivi.com/fill-pdf-form-fields/
However, with that solution you only get an FDF file... And the demo does not work for me, opening the FDF file simply downloads another FDF file.
Since this PDF will be available to the public we would like to keep it as simple as possible. If we must open our original PDF and import this FDF file, we need a different solution (which I'm not sure is what the FDF file is for, since it didn't work).
A related post talking about .net framework had the same idea, but there were only paid commercial solutions: From HTML form to PDF
The PHP solutions I have found so far are for creating a new PDF, which is not what I need. Our PDF is created with Adobe Illustrator (or a similar adobe product) and is high-res with embedded fonts, svg and image content.
The form elements are in place, we just need to get the data to there.
Update April 11, 2013:
Since posting this question I have been utilizing FPDF on multiple projects where I needed to accomplish this goal. Although it cannot seem to "merge" template PDFs with the provided data, it can create the PDF from scratch.
One example I have used, I had a high resolution PNG for printing (similar to initial question) which we had to write the customer's name and today's date clearly in the center. I simply made the background of the PDF using FPDF->Image() and write the text afterwards using FPDF->Text().
It was very simple after all, you will need to look up the paper sizes to determine the X,Y,W,H of the image and then base your text fields relative to those numbers.
There was even a Form Filling extension, but I couldn't get it to work.
It seems as though I should answer my own question, although Visions answer may be better (seems to be deleted?). I used Vasiliy Faronov's link which was a comment to my main question: https://stackoverflow.com/a/1890835/200445
Here I found how to install pdftk and run a command to merge (flatten) my FDF and PDF files. I still used the "hacky" way to generate an FDF using Koivi's FDF Generator but it works for the most part.
One caveat is that some characters, like single and double quotes are not inserted correctly. It may be an issue of escaping the fields, but I could not find an answer.
Regardless, my PDF form generator is working, but anyone with a similar issue should look for a better solution.
这篇关于将HTML表单提交至PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!