![](/img/trans.png)
[英]How to determine an end of a page before converting html to pdf using wkhtmltopdf?
[英]Converting html page containing openlayers map to pdf via wkhtmltopdf
我有 Html 页面包含表格和 OpenLayers 地图一切都在所有浏览器甚至 IE 上正常工作。 我想将此页面转换为 pdf,所以我使用了 wkhtmltopdf,当我使用幕后 WebKit 读取 wkhtmltopdf 来渲染页面时,我测试了Qt Web 浏览器上的输出,由于ol-debug.js:18601ReferenceError: Can't find variable: requestAnimationFrame
错误,浏览器拒绝显示 OpenLayers 地图ol-debug.js:18601ReferenceError: Can't find variable: requestAnimationFrame
ol.PluggableMap.prototype.render = function() {
if (this.animationDelayKey_ === undefined) {
this.animationDelayKey_ = requestAnimationFrame(
this.animationDelay_);
}
};
因为这个错误 wkhtmltopdf 只转换 Html 表并忽略地图
Ps:我使用这些命令进行转换
wkhtmltopdf.exe --enable-javascript --no-stop-slow-scripts --javascript-delay 2000 --debug-javascript
对此问题的解决方法的任何想法或建议
在此先感谢您的帮助
我发现使用 Chrome headless 是将 html 转换为 pdf 的更好和最快的选择
C:\\Google\\Chrome\\Applicationchrome.exe --headless --disable-gpu --run-all-compositor-stages-before-draw --virtual-time-budget=2000 --print-to-pdf=C: \\newPdf.pdf https://openlayers.org/en/latest/examples/animation.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.