qgis2web
qgis2web copied to clipboard
Can't save Openlayers map as PDF
The implementation fo the following code:
https://openlayers.org/en/v3.20.1/examples/export-pdf.html
doesn't work
Under the following line:
var pdf = new jsPDF('landscape', undefined, format);
console says, that
Uncaught ReferenceError: jsPDF is not defined
at e.<anonymous> (qgis2web.js:936)
at e.r (events.js:50)
at e.dispatchEvent (Target.js:115)
at e.dispatchRenderEvent (Composite.js:76)
at e.handlePostRender (PluggableMap.js:886)
After attaching the following scripts:
<script src="https://unpkg.com/elm-pep"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?
features=fetch,requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
The console says:
Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
at e.<anonymous>
(file:///C:/Users/mariuszk/Desktop/Voneous/Interactive/Area%205%20V1%20Interactive/resources/qgis2web.js:938:19)
at e.r (file:///C:/Users/mariuszk/Desktop/Voneous/Interactive/Area%205%20V1%20Interactive/resources/ol.js:1:24976)
at e.dispatchEvent
(file:///C:/Users/mariuszk/Desktop/Voneous/Interactive/Area%205%20V1%20Interactive/resources/ol.js:1:27459)
at e.dispatchRenderEvent
(file:///C:/Users/mariuszk/Desktop/Voneous/Interactive/Area%205%20V1%20Interactive/resources/ol.js:1:173800)
at e.handlePostRender
(file:///C:/Users/mariuszk/Desktop/Voneous/Interactive/Area%205%20V1%20Interactive/resources/ol.js:1:113977)
(anonymous) @ qgis2web.js:938
r @ events.js:50
e.dispatchEvent @ Target.js:115
e.dispatchRenderEvent @ Composite.js:76
... and so on
The answer here:
https://stackoverflow.com/questions/31279582/openlayers-failed-to-execute-todataurl-on-htmlcanvaselement
says, that it must be the local proxy
I found another solution here:
https://www.reddit.com/r/learnprogramming/comments/7kxpdk/export_wms_layer_to_pdf_using_openlayers_and/
but it applies to PNG and JPEG.
How can I enable the PDF download (or at least PNG download) option for my openlayers map generated by QGIS2web plugin?