HTML为PDF高分辨率 [英] HTML To PDF High Resolution

查看:166
本文介绍了HTML为PDF高分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

使用PHP将HTML + CSS转换为PDF?


我想将网页转换为适合打印的高分辨率PDF。如何使用浏览器转换网页,您可以在windows中使用软件如cutepdf, dopdf等
,但如果你想通过php代码(即时)将网页转换为pdf,有几种转换方法:


  1. 使用提供的库,您可以尝试 html2pdf (php)。
    在java / .net中可以使用类似 pd4ml 的库(即使它不是免费的)。


  2. 您可以使用open office转换器。它可以打开多个文档类型,并转换成pdf。开放式办公室提供的API(我曾尝试在Java中,而不是PHP)。流程与您打开文档相同,然后转换为pdf,但您只需在编码中进行。必须有开放式办公服务器守护程序通过您的代码来收听转换器。请参阅 http://oodaemon.sourceforge.net/


如果您想在PHP中快速解决问题,也许可以使用html2pdf。



办公转换器的输出将与您在浏览器中看到的相同(我已经测试过使用oodaemon)。如果使用库,我不确定100%,如果您在浏览器中打开它,它将会是相同的,因为布局取决于CSS。 pd4ml基于html和css生成PDF格式的布局(它拥有CSS解析器,我认为)


Possible Duplicate:
Convert HTML + CSS to PDF with PHP?

I want to convert a web page to a high-resolution PDF suitable for printing. How can I do this?

解决方案

if you want to convert web page using browser, you can use sofware in windows like cutepdf, dopdf etc. but if you want to convert a web page into pdf by php code (on the fly), there are several ways to convert:

  1. Using library provided, you can try html2pdf (php). In java / .net a library like pd4ml can be used (even it is not free).

  2. You can use open office converter. It can open multiple doc type, and convert into pdf. Open office provide API (I have tried in java, not php). The flow is same like you open the document, then convert into pdf, but you just do it in your coding. Must have open office server daemon to listen the converter via your code. See here http://oodaemon.sourceforge.net/

If you want quick solution in PHP, maybe you can use html2pdf.

The advantage you use open office converter is the output will be same as you see in browser (I already test it use oodaemon). If using library I am not sure 100% it will be same if you open in browser, because the layout is depend on CSS. pd4ml generate layout in pdf base on html and css (has it owns CSS parser I think)

这篇关于HTML为PDF高分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆