Developer
Developer

Reputation: 85

doc.addImage is not a function error in jspdf using in Angular 6

I am Using Latest Version of jsPDF (1.5.2) in angular 6

Source Code

public captureScreen()  
{  
    var data = document.getElementById('contentToConvert'); 
    html2canvas(data).then(canvas => { 
    // Few necessary setting options 
    var imgWidth = 208; 
    var pageHeight = 295; 
    var imgHeight = canvas.height * imgWidth / canvas.width; 
    var heightLeft = imgHeight; 

    const contentDataURL = canvas.toDataURL('image/png');
    let doc = new jsPDF('p', 'mm', 'a4'); // A4 size page of PDF 
    var position = 0; 
   // pdf.text("Octonyan loves jsPDF", 35, 25);
    doc.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight) ;
    doc.save('MYPdf.pdf'); // Generated PDF  
    }); 

} 

in node_modules jspdf > dist folder contain these files

enter image description here

error Message

core.js:1673 ERROR Error: Uncaught (in promise): TypeError: doc.addImage is not a function TypeError: doc.addImage is not a function
at movielists.component.ts:301

Upvotes: 2

Views: 1346

Answers (1)

user3619994
user3619994

Reputation: 61

Today version 1.5.3 got released and fixes those issues.

Upvotes: 1

Related Questions