Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

294
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda