I'm getting PDF with cut images on safari browser, while other browsers shows them correctly.
I'm using html2canvas and jsPDF to export an image of morris charts, apexcharts and html tables. This is the code:
html2canvas(document.getElementById(id_div))
.then((canvas) => {
var w = document.getElementById(id_div).offsetWidth;
var h = document.getElementById(id_div).offsetHeight;
var img = canvas.toDataURL("image/jpeg", 1);
if (w > h) {
var doc = new jsPDF("l", "mm", [w + 100, h + 50]);
} else {
var doc = new jsPDF("p", "mm", [h + 100, w + 50]);
}
doc.addImage(img, "JPEG", 10, 10);
doc.save("chart.pdf");
})
.catch(function (e) {
console.log(e.message);
});
This is what I get on chrome (correct):
And this is what I get on safari (wrong):
What could be the problem and how I solve it? Thanks for the help.