wordpress 你怎么能在wordpress中动态创建一个pdf?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13133066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:03:35  来源:igfitidea点击:

How could you dynamically create a pdf within wordpress?

wordpresspdfpdf-generationtcpdffpdf

提问by user1784593

I'm using a Contact Form 7 to have the users enter data, then based on their data entry, I need to add different text to the pdf before outputting the entire pdf.

我正在使用联系表 7 让用户输入数据,然后根据他们的数据输入,我需要在输出整个 pdf 之前向 pdf 添加不同的文本。

For example, if the user says they like red balloons, the created balloon pdf will mention how important red balloons are, etc...

例如,如果用户说他们喜欢红色气球,那么创建的气球 pdf 会提到红色气球的重要性等等......

I know there must be a way to do this using fpdf, tcpdf, or something, but I'm not sure how. Any ideas?

我知道必须有一种方法可以使用 fpdf、tcpdf 或其他东西来做到这一点,但我不确定如何。有任何想法吗?

回答by Ashwin Muni

Take a look at dompdfIts is very easy to use as well as good implementation documentation.

看看dompdf非常好用,还有很好的实现文档。

回答by yedidel

First of all I really recommend using Gravity Forms, it's a better plugin for forms and it also saves entries in the database so you can retrieve them.

首先,我真的建议使用 Gravity Forms,它是一个更好的表单插件,它还可以将条目保存在数据库中,以便您可以检索它们。

For the PDF part, I think you need to program it manually.

对于PDF部分,我认为您需要手动对其进行编程。

Create a php file that implements tcpdf, and receives all input from the form (via POST or GET). Then you have all the parameters you need and you can create the PDF in any way you like.

创建一个实现 tcpdf 的 php 文件,并接收来自表单的所有输入(通过 POST 或 GET)。然后你就拥有了你需要的所有参数,你可以以任何你喜欢的方式创建 PDF。

In order to use this php file, open a Page in Wordpress and then rename the php file to page-.php (where XXXX is the new Page ID you opened)

为了使用这个 php 文件,在 Wordpress 中打开一个页面,然后将 php 文件重命名为 page-.php(其中 XXXX 是您打开的新页面 ID)

回答by Chris Vogt

You may wish to use PHP's native PDF functions wrapped in a custom Wordpress plugin to generate your own PDF documents. Check out the PHP.net Manual: PDFfor an overview. I'm there there are plenty of PHP=>PDFvendor libraries out there if you search the Google's.

您可能希望使用封装在自定义 Wordpress 插件中的 PHP 原生 PDF 函数来生成您自己的 PDF 文档。查看PHP.net 手册:PDF以获得概述。PHP=>PDF如果你搜索谷歌,那里有很多供应商库。

Another solution, off the top of my head, would be to run a worker process somewhere to convert and return documents in [?|PDF] formats based on Wordpress data fed through a template system (mustache, twig, etc).

另一种解决方案是在某个地方运行一个工作进程,根据通过模板系统(mustache、twig等)提供的 Wordpress 数据转换和返回 [?|PDF] 格式的文档。

回答by Sandeep Pattanaik

install the pdf creator plugin from this url. Hope this help you.

从此 url 安装 pdf creator 插件。希望这对你有帮助。

http://wordpress.org/extend/plugins/kalins-pdf-creation-station/

http://wordpress.org/extend/plugins/kalins-pdf-creation-station/