在提交操作时将数据插入 PDF,填写在线表格

发布于 2024-09-09 04:56:40 字数 1032 浏览 2 评论 0原文

首先,我向所有认为这个问题重复出现或发现与此类似的问题的人表示歉意。

我正在开发一个项目,其中有一个在线表单和一些 PDF 存储在服务器上。

功能

在提交操作中,我必须从表单中获取数据,将其填充到 PDF 副本中,最后下载它。

方法

我按照以下步骤来实现此功能:

问题

  • 该方法是一种暴力方法,因为生成的 html 与真实的 html 相差很远。这样就浪费了很多精力在调整html上。
  • 该过程非常缓慢且不可靠,因为大多数时候我都会遇到内存错误或其他一些问题。

我需要自动化这个过程。我通过搜索发现,我应该创建一个包含变量的 FDF 文件,并使用某个库将其传递给 PDF,然后下载它。

我能够创建 FDF 文件,但缺少 PHP 中的任何库(我在 JAVA 中找到了一个库),我可以用它来创建 PDF 并下载它。我发现的一个库是 pdf 工具包,但这是一个命令行工具,我无法在运行时在服务器上使用它并下载 PDF 文件。

任何以前做过此操作的人请帮忙。

(抱歉这篇长文)

谢谢,

Madhup

First of all my apologies to all the people who think this question is a repeated one or they find a similar question to this.

I am working on a project in which I have an online form and some PDFs stored on the server.

Functionality

On the submit action I have to get the data from the form, fill it to the copy of PDF and finally download it.

Approach

I followed these steps to achieve this functionality:

Problem

  • The approach is a brute force one as the html generated are far away from the real ones. So lot of effort is wasted in adjusting the html.
  • The process is so slow and not reliable as most of the time I get memory error or some other issues.

I need to to automate this process. What I have found through searching is I should create an FDF file that contains my variable and pass it to the PDF using some library and then download it.

I am able to create the FDF file but missing any library in PHP (I found one in JAVA) that I can use to create the PDF and download it. One library that I found is pdf tool kit but that is a command line tool and I am not able to use it on the server at run time and download the PDF file.

Anybody having done this before please help.

(Sorry for this long post)

Thanks,

Madhup

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

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

发布评论

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

评论(1

胡渣熟男 2024-09-16 04:56:40

查看 FPDI。它允许您加载一些现有的 PDF,以编程方式在其上绘图,然后输出新的 PDF。如果我没理解你的问题,这就是你想要做的。

此处有一些示例代码。

Check out FPDI. It allows you to load some existing PDF, draw on it programatically, and output a new PDF. Which, if I read your question right, is what you're trying to do.

There's some example code here.

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