mycomponent.ts
import jsPDF from 'jspdf';
import autoTable from 'jspdf-autotable';
export class Component implements OnInit {
.
.
.
exportPdf() {
const doc = new jsPDF('p', 'pt');
columns = [...]
autoTable(doc, {
columns: this.columns,
body: this.data,
didDrawPage: (dataArg) => {
doc.text('data', dataArg.settings.margin.left, 10);
}
});
doc.save('data.pdf');
}
}
package.json
"dependencies": {
"jspdf": "^2.5.1",
"jspdf-autotable": "^3.5.23"
}
I installed my npm packages with npm i jspdf and npm i jspdf-autotable but the same errors persist. I don't understand what should I do. Are the versions wrong?
CodePudding user response:
You have to install @types/jspdf
and @types/jspdf-autotable
as dev-dependencies.
If you use yarn
:
yarn add -D @types/jspdf @types/jspdf-autotable
For npm
use:
npm install @types/jspdf @types/jspdf-autotable --save-dev