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

339
Visualizações
Laravel JSPDF output() not working but save() is working

I have Laravel project that use JSPDF to generate PDF file from a DIV and download it

When I tried it on iPhone Safari I found that it's not working

I searched about the reason and I found that I can use output('dataurl') instead

When I replaced the save() with output(), it's not working on all platforms now

The code:

$('#print').click(async function (e) {
    e.preventDefault();
    const pdf = new jsPDF('p', 'mm', 'a4');
    const imgWidth = 208;
    const position = 0;

    let page1 = document.querySelector('#report-one');
    let page2 = document.querySelector('#report-two');
    const [imgPage1, imgPage2] = await Promise.all([html2canvas(page1), html2canvas(page2)]);
    // Process first image
    let imgHeight = imgPage1.height * imgWidth / imgPage1.width;
    let contentDataURL = imgPage1.toDataURL('image/jpeg');
    pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);
    pdf.addPage();
    // Process second image
    imgHeight = imgPage2.height * imgWidth / imgPage2.width;
    contentDataURL = imgPage2.toDataURL('image/jpeg');
    pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);

    pdf.output('dataurl');
});
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