Wkhtmltopdf OpenLayers V3 failed

I am trying to create a pdf file with wkhtmltopfd from an OpenLayer V3 card, but I only get a blank image.

This code should generate PDF with map images, but it only generates map background.

wkhtmltopdf --javascript-delay 5000 http://openlayers.org/en/v3.1.1/examples/moveend.html test.pdf 

What am I doing wrong?

This is what I already checked:

  • I opened a webpage in Chrome and saved it as a PDF. He works.
  • On Wireshark, I don’t see any request for a tile image (so the blocking tile server is not a failure).
  • I tried some options in wkhtmltopdf, for example --background and --images , but without success (these options are also marked as default options).
  • I am using wkhtmltopdf 0.12.1.2 (with qt fixed) on Windows 8. Success.
  • Also wkhtmltopdf 0.12.1 (with qt fixed) on Ubuntu 14: no success.
+5
source share
1 answer

Use the window status switch "--windows-status XXXX". If you add this switch, the PDF component (wkhtmtopdf) will wait for the window status. As soon as the script installs a ready-made sataus window or anything specified in the wkhtmltopdf switch, start converting html to PDF.

What you need to do .... Try to find when your maps are loaded in the DOM and everything worked (ajax calls or any long running script was executed / successfully), then set window.sataus = "ready" (using java script)

add switch --wowow-status ready

wkhtmltopdf --window-status ready http://openlayers.org/en/v3.1.1/examples/moveend.html test.pdf

+1
source

Source: https://habr.com/ru/post/1211592/


All Articles