gpt4 book ai didi

php - 使用php将网页打印为pdf文档

转载 作者:行者123 更新时间:2023-12-02 08:38:02 25 4
gpt4 key购买 nike

我可以看到有几个选项可以做到这一点。我的问题是,有谁知道一种方法,我可以简单地将 php 网页传递给 pdf 创建器,并且它的输出与通过浏览器查看的内容完全相同?考虑CSS、图像和php函数等。

谢谢

最佳答案

思考wkhtmltopdf是您正在寻找的答案,因为它使用 WebKit呈现网页就像在浏览器中一样,然后将其转换为 PDF。这节省了您编写大量 PHP 代码来组织 PDF 布局的时间。

来自他们网站的详细信息:

Simple shell utility to convert html to pdf using the webkit rendering engine, and qt.

Searching the web, I have found several command line tools that allow you to convert a HTML-document to a PDF-document, however they all seem to use their own, and rather incomplete rendering engine, resulting in poor quality. Recently QT 4.4 was released with a WebKit widget (WebKit is the engine of Apples Safari, which is a fork of the KDE KHtml), and making a good tool became very easy.

  • Convert web pages into PDF documents using webkit
  • Adding headers and footers (static version only)
  • TOC generation (static version only)
  • Batch mode conversions
  • (Linux) No longer requires an XServer to be running (however the X11 client libs must be installed)

有关 wkhtmltopdf 的代码和更多信息与 PHP 集成请参阅 https://github.com/aur1mas/Wkhtmltopdf

关于php - 使用php将网页打印为pdf文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5142080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com