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
Cross Domain images not rendering (No CORS or proxy) #592
Comments
Maybe You should use |
Using |
Did yo try my fix? #554 |
Probably should set |
I don't understand why not use the |
@brcontainer Because they don't work in the latest version, see my fix: #554 |
@Cristy94 Sure!! Great fix! Thanks! |
Hi @Cristy94, I am fetching the images from CMS(Contentful) in my HTML and then trying to generate PDF of that HTML. function downloadPDF() { var canvasShiftImage = function(oldCanvas,shiftAmt){ var newCanvas = document.createElement('canvas'); var img = canvasToImage(oldCanvas); return newCanvas; var canvasToImageSuccess = function(canvas){ while(totalPdfHeight < htmlPageHeight && safetyNet < 15){ totalPdfHeight += (pdfPageHeight * pdfScaleFactor * htmlScaleFactor); if(totalPdfHeight < htmlPageHeight){ var pageName = document.location.pathname.match(/[^/]+$/)[0]; html2canvas($('body')[0], |
Hey, will there be a fix for that? CORS images not rendered here as well :( |
Hi Rookev, You can do so by passing one of the option in html2canvas function. And trust me this will surely work :) html2canvas($('#div_pdf')[0], |
Hi @gauravmishra24, unfortunately this does not work. The problem is that I want to include images from a server where the server has the flag
not set :( |
Hi Rookev, Could you please post your code snippet? So that I can have a better look on the same..... |
Hi, Is there any fix for this? Even with useCORS set to true, images are not getting downloaded. Still get the cross-origin error as mentioned above. Also, not sure about Cristy94's solution in distributed html2Canvas.js file. Even after changing code in distributed file, as per 87d4435 it doesn't work either. For the other alternative, with proxy settings, is there any solution for angular 2 application? |
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. |
@niklasvh Here is my example on codepen with v1.0.0: |
Is there any other plugin anyone knows. This was not working with different servers request. No proper example given for proxy. |
@vinayistar you can try my changes see link #1544 (comment) |
Using |
|
My solution to this problem is converting the image src to Base64 const img = document.querySelector('#img')
fetch(img.src)
.then(res => res.blob())
.then(blob => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
})
)
.then(dataURL => {
img.src = dataURL
return html2canvas(element)
} ) |
@todoi Can you provide the sample of this with jspdf. |
@nishanta454
|
I solved this problem by adding proxy: ( image src )option in html2canvas. Now your image is also included in pdf .tsdownload() { .html |
@sanjilshakya |
I don't understand very well about proxy, but what would a proxy be? how do i add it to my project to solve this problem? |
Hi,
Using the following code images are not rendering cross-domain.
Whilst trying to grab images from "http://www.thermmark.co.uk" from "http://www.playgroundmarkingsdirect.co.uk" the images would not render.
When I moved the code over to the "http://www.thermmark.co.uk" website the images rendered (I own both domains)
Any ideas?
The text was updated successfully, but these errors were encountered: