JS PDF - Export with html Canvas

Asked

Viewed 565 times

0

inserir a descrição da imagem aqui

I am using Jspdf now with the method that it takes the screen print and then exports this print to pdf , but when generating the pdf I would like to leave more adjusted the screen. When I use Landscape (Landscape) it looks like the image above , with a line in the middle and does not fit the screen entirely well.

and when I use Portrait it looks just like in the image below all misaligned

inserir a descrição da imagem aqui

So I was wondering if you had anything that could fix this problem. follows the code I am currently using to export the screen print to pdf.

     function genPDF(){
     html2canvas(document.body,{
     onrendered: function (canvas){


      var img =canvas.toDataURL("image/png");
      var doc = new jsPDF("l", "mm", [297, 210]);

      var width = doc.internal.pageSize.width;    
      var height = doc.internal.pageSize.height;


      doc.addImage(img , 'JPEG'  ,0, 0, width, height);
      doc.save('test.pdf');


}

})



}</script>
  • Can you tell if your page is responsive? Try to adjust your html to be responsive, so use bootstrap, I believe this will adjust the export.

  • @Carlosh yes , my table and page are responsive made with bootstrap

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.