Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
html2canvas and jsPDF issue on Safari: cut images

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):

enter image description here

enter image description here

And this is what I get on safari (wrong):

enter image description here

enter image description here

What could be the problem and how I solve it? Thanks for the help.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!