Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't save Openlayers map as PDF #934

Open
Krukarius opened this issue Nov 13, 2020 · 0 comments
Open

Can't save Openlayers map as PDF #934

Krukarius opened this issue Nov 13, 2020 · 0 comments

Comments

@Krukarius
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant