简体   繁体   English

使用wkhtmltopdf将HTML转换为PDF

[英]Html to PDF using wkhtmltopdf

I am trying to creat my reporting system using html and transforming it into pdf. 我正在尝试使用html创建我的报告系统,并将其转换为pdf。 I am using wkhtmltopdf, and what i have done is creating the report in a url and calling in using wkhtmltopdf, but when url takes to long to load the conversion fails. 我正在使用wkhtmltopdf,我所做的就是在url中创建报告并使用wkhtmltopdf进行调用,但是当url花很长时间才能加载转换时,会失败。

Does anyone have experience with converting html to pdf? 有没有人有将html转换为pdf的经验? or is the technology not ready yet? 还是技术还没有准备好?

After many problems with other libraries I used mPDF and it worked very good. 在其他库遇到许多问题之后,我使用了mPDF,它的效果很好。 Download the latest version, read documentation here ( http://www.mpdf1.com/ ). 下载最新版本,请在此处阅读文档( http://www.mpdf1.com/ )。

Although you have moved to different library, I am still answering here so that it can be helpful to other users facing the same issue. 尽管您已移至其他库,但我仍在此处回答,以便它对面临相同问题的其他用户有所帮助。

The trick is to use 诀窍是使用

javascript-delay JavaScript的延迟

option of wkhtmltopdf where value is given in ms. wkhtmltopdf的选项,其中值以毫秒为单位。

eg: 例如:

wkhtmltopdf --javascript-delay 1000 http://your.url.com pdf_name.pdf wkhtmltopdf --javascript-delay 1000 http://your.url.com pdf_name.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM