javascript - wkhtmltopdf.exe --no-stop-slow-scripts 不起作用?

标签 javascript jquery html pdf wkhtmltopdf

我们正在使用 wkhtmltopdf.exe (0.10.0 rc2) 将包含大量 JavaScript 的非常大的 HTML 页面转换为 PDF 文件。在执行所有 JavaScript 之前,我们遇到了打印 PDF 的问题,因此我们决定在执行 wkhtmltopdf 时使用以下参数(以及其他参数):

wkhtmltopdf.exe --no-stop-slow-scripts --javascript-delay 40000 <url> <pdf>

但是,输出仍然向我们发出警告,表明慢速脚本已停止。当我们检查PDF时,某些应该被javascript隐藏的元素仍然可见(所以我认为javascript无法及时执行)。当我检查 HMTL 页面时,一切看起来都很正常,并且控制台中没有显示 javascript 错误。我尝试了上述两个参数的所有可能组合,但没有任何结果。

>wkhtmltopdf.exe --no-stop-slow-scripts --javascript-delay 40000 
--print-media-type --no-outline --title "My title" --footer-center "My footer"
--footer-font-name "Verdana" --footer-font-size 4 --no-footer-line 
--cookie MyCookie MyCookieKey=MyCookieValue 
"http://..." "C:\Users\...\Documents\TestPDF.pdf"

Loading pages (1/6)
Warning: A slow script was stopped      <<< Why does it still show this warning?
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

那么为什么 wkhtmltopdf 会忽略这些参数呢? 难道和wkhtmltopdf的版本有关系吗?或者可能是由于这些 HTML 页面中使用了 jQuery 造成的?

任何帮助将不胜感激!

最佳答案

此问题的解决方案是更新到最新版本 (0.12.3.2)。在此版本中,我们甚至不再需要 --javascript-delay--no-stop-slow-scripts...

关于javascript - wkhtmltopdf.exe --no-stop-slow-scripts 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36628179/

相关文章:

javascript - 我的第一个 casper.js 脚本是从 python 调用的

jquery - 使用 jquery 查找 <ul> 中的最后一行并应用一个类

jquery - 访问选项卡时网站无法重新加载的问题

image - 将多个图像保存为视频格式的可能性?

javascript - CSS3 : remove background from button when dropdown is close

javascript - HTML 选择下拉列表与 JavaScript 函数

javascript - Angular JS 中的数组长度

javascript - 在创建新实例的构造函数闭包内更改 "var"

javascript - jQuery:悬停时隐藏div,点击时保持可见

jquery - 按钮上的标签剥离效果