Noa
Noa

Reputation: 355

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

Upvotes: 0

Views: 435

Answers (1)

Noa
Noa

Reputation: 355

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

Upvotes: 0

Related Questions