Open AnAnUncle opened 2 years ago
thanks for @christiansaavedra @guttenberger
Is it resolved now ? useCORS : true
is not working. My img tag also enables CORS bt no luck
My options are:
var opt = {
useCORS: true,
enableLinks: true,
margin: 20,
filename: filename,
};
My html of the image that is not rendering is:
<img crossorigin="true" alt="logo" src="https://domain.eu-central-1.amazonaws.com/assets/logo/company.png" class="">
Found a Solution 👍
Add useCORS: true
inside the html2canvas
tag that will work.
var opt = {
// useCORS: true,
enableLinks: true,
margin: 20,
filename: filename,
html2canvas: {useCORS:true},
};
Complete code:
const element = document.getElementById("invoice");
var opt = {
// useCORS: true,
enableLinks: true,
margin: 20,
filename: filename,
html2canvas: {useCORS:true},
};
html2pdf()
.set(opt)
.from(element)
.save();
1.Allow CORS in your server. 2.add useCORS: true const opt = { margin: 0, filename: 'myfile.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { allowTaint: true, scale: 2, useCORS: true, }, jsPDF: { unit: 'in', format: 'a4', }, }; const worker = html2pdf().set(opt).from(html);