0

When trying to add an Image with jsPDF i get the following console error:

Access to XMLHttpRequest at 'https://batemo.de/wp-content/uploads/pdf_logo.jpg' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
xhr @ jspdf.debug.js:11878
jsPDFAPI.loadFile @ jspdf.debug.js:11891
createDataURIFromElement @ jspdf.debug.js:7038
jsPDFAPI.addImage @ jspdf.debug.js:7562
batemoLogo.onload @ cell_finder.html:307
load (async)
(anonymous) @ cell_finder.html:306

I use the follwing code:

var batemoLogo = new Image();
        batemoLogo.src = 'https://batemo.de/wp-content/uploads/pdf_logo.jpg';
        batemoLogo.onload = function() {
        doc.addImage(batemoLogo, 5, 5, 180, 160);};
        var imgWidth = doc.internal.pageSize.getWidth()*0.9;
        imgX = doc.internal.pageSize.getWidth()*0.1/2;
        doc.addImage(ScatterChart.getChart().getImageURI(), imgX, 100, imgWidth, 300);

What can I do to fix this?

Björn
  • 35
  • 7
  • Do the url belongs to you? If not, you can't solve it on client side. – Elias Soares Mar 29 '20 at 18:27
  • if it's belongs to client side, refer to this answer if it helps: https://stackoverflow.com/questions/60669860/cors-issues-when-using-a-fetch-request-to-call-amazon-web-services-cloudsearch/60670570#60670570 – Zain Ul Abideen Mar 29 '20 at 18:30

0 Answers0