0

我有 Html 页面包含表格和 OpenLayers 地图在所有浏览器甚至 IE 上一切正常。我想将此页面转换为 pdf,所以我使用 wkhtmltopdf 并在阅读 wkhtmltopdf 时使用幕后 WebKit 呈现页面,因此我在Qt Web 浏览器上测试输出,由于错误,浏览器拒绝显示 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

有关此问题的解决方法的任何想法或建议

在此先感谢您的帮助

4

1 回答 1

0

我发现使用 Chrome 无头是将 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

于 2018-11-07T23:16:04.203 回答