Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

290
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda