Reputation: 85
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
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