简体   繁体   中英

Converting html page containing openlayers map to pdf via wkhtmltopdf

I have Html page contains tables and OpenLayers map Everything works ok on all the browsers even IE. I want to convert this page to pdf so I used wkhtmltopdf and as I read wkhtmltopdf using behind the scene WebKit to render the page so I test the output on Qt Web Browser the browser refuses to display the OpenLayers map due to the error ol-debug.js:18601ReferenceError: Can't find variable: requestAnimationFrame

ol.PluggableMap.prototype.render = function() {
  if (this.animationDelayKey_ === undefined) {
    this.animationDelayKey_ = requestAnimationFrame(
        this.animationDelay_);
  }
};

because this error wkhtmltopdf convert only the Html tables and ignore the map

Ps: I use those command for converting

wkhtmltopdf.exe --enable-javascript --no-stop-slow-scripts --javascript-delay 2000 --debug-javascript

any idea or suggestion for a workaround for this issue

thanks in advance for the help

I found out using Chrome headless is the better and fastest option in converting html to 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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