dompdf定制问题
我正在尝试优化 dompdf 来做一些有点奇怪的事情。由于它在我的服务器上,dompdf 正在从存储在服务器上某处的 php/html 文件生成一个 pdf 文件(供请求该文件的客户端使用)。这很酷,因为它不会因为 pdf 文件而使服务器陷入困境,但我遇到的问题是我希望有人能够导出一组 PDF 并以 zip 文件或类似文件的形式接收它们。
有没有办法让 dompdf 根据 php/html 文件的文件名将一组 PDF 文件导出到 zip 文件或其他文件,以便请求者可以下载它?
如果需要更多信息,请告诉我。
谢谢你!!
I'm trying to optimize dompdf to do something a bit strange. As it is on my server, dompdf is generating a pdf file (for the client requesting the file) from a php/html file stored somewhere on the server. This is cool because it doesn't bog the server down with pdf files, but the problem I have is that I want someone to be able to export a group of PDFs and receive them in a zip file or something similar.
Is there a way to make dompdf export a group of PDF files, based on the filenames of the php/html files, to a zip file or something so the person requesting it can download it?
Let me know if more information is needed.
Thank you!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DOMPDF 一次仅处理一个文件。但是您可以编写一个 PHP 脚本来接受文件列表,然后使用 DOMPDF 单独解析每个文件。由于 DOMPDF 可以将渲染的 PDF 作为字符串返回,因此您可以将每个文件写入临时目录,然后在完成后存档结果。或者,如果您使用 dompdf.php,则可以使用 exec() 在类似的循环中处理每个 HTML 文档。
下面是一个简单的示例,展示了一种执行您想要的操作的方法:
论坛 和 问题跟踪器。
DOMPDF only handles a single file at a time. But you could write a PHP script to accept the list of files and then use DOMPDF to parse each one separately. Since DOMPDF can return the rendered PDF as a string you could write each file out to a temporary directory then archive the results when you're done. Or, if you're using dompdf.php you could use exec() to process each HTML document in a similar loop.
Here's a simple example showing one way to do what you want:
There are some discussions of using DOMPDF to batch process files in the forum and issue tracker.