Monday, 24 August 2020

How to print full screen using jspdf and html2canvas

Hi i am using Angular8 in my application. Here i have used jspdf and html2canvas for converting html to pdf. But i am able to print only half page not the full page. Can anyone help me where i am going wrong.

TS:

 public downloadPdf() {
    var data = document.getElementById('pdfDownload');
    html2canvas(data).then(canvas => {
      // Few necessary setting options
      var imgWidth = 208;
      var imgHeight = canvas.height * imgWidth / canvas.width;
      alert(imgHeight)
      const contentDataURL = canvas.toDataURL('image/png')
      let pdf = new jspdf('p', 'mm', 'a4'); // A4 size page of PDF
      var position = 0;
      pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);
      //  pdf.save('new-file.pdf');
      window.open(pdf.output('bloburl', { filename: 'new-file.pdf' }), '_blank');
    });
 
  }


from How to print full screen using jspdf and html2canvas

No comments:

Post a Comment