使用 PHP 将字段绑定到 PDF 模板

发布于 2024-08-23 19:00:22 字数 544 浏览 4 评论 0原文

我有很多客户,每个客户都给我发送了许多申请表的 pdf 模板。我的客户希望我从数据库导出用户信息并将其绑定到模板。

例如,我有一个名为“健身表格”的 pdf 文件,其中有空字段(文本、复选框),例如名字、姓氏、身高、体重等...我需要从数据库中获取所有客户信息.t_user 表(t_user.first_name、t_user.last_name、t_user.height 等...)并将其绑定到此 pdf 模板。

此外,我还会有第二个 pdf 文件,名为“跆拳道锦标赛申请表”,其中可能有类似的字段,如名字、姓氏、身高、体重,但也可能有新字段,如获胜、失败、技术淘汰赛等。 ..

我想要一个过程,允许不懂技术的人能够将我的 t_user 表中的列映射到这些 pdf 模板。然后他们可以按“生成 pdf”来填写 pdf 模板中的所有字段。

目前,我正在考虑使用 fpdf 库构建一些东西,以便不懂技术的人可以使用 Adob​​e Acrobat 在 pdf 模板中绘制可绑定字段。然后我将创建一个 Web 应用程序,让他们将 fpdf 字段名称映射到我的数据库列名称。

谁能推荐更好的方法?

I have various clients each sending me many pdf templates of application forms. My clients want me to export user information from my database and bind it to the templates.

So for example, I have a pdf called "Fitness Form" and in it are empty fields (text, checkboxes) such as first name, last name, height, weight etc... I need to take all the customer information from my db.t_user table (t_user.first_name, t_user.last_name, t_user.height etc...) and bind it to this pdf template.

Additionally, I'll have a second pdf called "Kickboxing Tournament Application" and in it might be similar fields like first name, last name, height, weight, but it might also have new fields such as wins, losses, technical knockouts etc...

I want a process that allows non-tech savvy people to be able to map columns in my t_user table to these pdf templates. Then they can press a "generate pdf" to fill out all the fields in the pdf template.

At the moment, I'm considering building something with the fpdf library so nontechsavvy people can use Adobe Acrobat to draw bind-able fields in the pdf template. Then I'll create a web application that let's them map fpdf field names to my database column names.

Can anyone recommend a better approach?

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

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

发布评论

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

评论(3

罪歌 2024-08-30 19:00:22

运行 SELECT 语句,然后:
以您认为合适的方式构建 HTML,

引用 $row First Name:等

为 html 中与您从表中提取的每个字段相对应的每个字段

Run your SELECT statement, then:
Build your HTML in the manner you see fit, referencing the $row

First Name:

etc for each field in your html that corresponds to each field you pulled from your table

陈独秀 2024-08-30 19:00:22

我将在 HTML 中重新创建 PDF,并使用 wkhtmltopdf 使用 HTML 模板 + 您的数据生成 PDF。

您可以将它们设置为使用 WYSIWYG 来设计 HTML 并使用它们放置的字符串(例如 {FirstName})来创建替换。

这至少是一条简单的路线,取决于您认为用户有能力处理什么。

I would recreate the PDF in HTML and use wkhtmltopdf to generate the PDF using the HTML template + your data.

You could set them up to use a WYSIWYG to design the HTML and use strings such as {FirstName} they would place to create the replacements.

That's the easy route at least, depends on what you think the user is capable of handling.

迷爱 2024-08-30 19:00:22

我最终使用adobe的FDF技术将数据绑定到pdf模板(因为客户不会接受我从头开始创建的任何pdf模板)。

I ended up using adobe's FDF technology to bind data to pdf templates (because clients will not accept any pdf templates that I create from scratch).

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