【问题标题】:Converting html page containing openlayers map to pdf via wkhtmltopdf通过 wkhtmltopdf 将包含 openlayers 映射的 html 页面转换为 pdf
【发布时间】:2018-11-06 22:13:23
【问题描述】:

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

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

提前感谢您的帮助

【问题讨论】:

    标签: javascript openlayers wkhtmltopdf html-to-pdf wkhtmltopdf-binary


    【解决方案1】:

    我发现使用 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多