download() {
var columns = [
{ title: "Producto", dataKey: "producto" },
{ title: "Fecha", dataKey: "fecha" }
];
var data = [{ "producto": "ddf", "fecha": "cwx" }];
var doc = new jsPDF('p', 'pt');
console.log("1", data);
console.log("2", columns);
doc.autoTable(columns, data);
doc.save('table.pdf');
//console.log("3", data);
//this.PdfServiceService.getAll().subscribe(c => {
// console.log("4", this.country = c.pdfdata)
// this.data = this.country;
//});
};
<button (click)="download()">Generate PDF</button>
I want to pass data (var data
) through JSON data. I'm not able to pass the data into the doc auto table. This is the link I have tried: https://www.npmjs.com/package/jspdf-autotable
Just add values in data and use array of arrays
[ [],[]]
and it will work.