0

generatePDF() {
  var data = document.getElementById('a'); 
  html2canvas(data).then(canvas => {

     // Few necessary setting options 
     var imgWidth = 200; 
     var imgHeight = canvas.height * imgWidth / canvas.width; 

     const contentDataURL = canvas.toDataURL('image/png') 
     let pdf = new jspdf('p', 'mm', 'a4'); // A4 size page of PDF 

     pdf.addImage(contentDataURL, 'JPEG', 10, 10, imgWidth, imgHeight);
     var string = pdf.output("datauristring"); // Generated PDF  
     var iframe = "<iframe width='100%' height='100%' src='" + string + "'></iframe>";
     $('#test').html(iframe);

 }); }

|