Property 'autoTable' does not exist on type jsPDF
I am using angular2 and Node JS. I have installed jspdf and jspdf-autotable both modules using npm. and in .angular-cli.json file , I have embedded the scripts:
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
In my component.ts file , I have imported these files as follows:
import * as jsPDF from 'jspdf';
import * as autoTable from 'jspdf-autotable';
In function of component.ts file I am using sample code as follows:
var columns = ["ID", "Country", "Rank", "Capital"];
var data = [
[1, "Denmark", 7.526, "Copenhagen"],
[2, "Switzerland", 7.509, "Bern"],
[3, "Iceland", 7.501, "Reykjavík"],
[4, "Norway", 7.498, "Oslo"],
[5, "Finland", 7.413, "Helsinki"]
];
var doc = new jsPDF();
doc.autoTable(columns, data);
doc.output("dataurlnewwindow");
But now when I run the node command to start app then during compilation I am getting error as Property 'autoTable' does not exist on type 'jsPDF'.
I have console the doc object and found autoTable exists there but don't know why it is creating error?

Can any one please suggest?
Try replacing import * as autoTable from 'jspdf-autotable'; with import 'jspdf-autotable'
It is working now. actually I was importing both jspdf and jspdf-autotable, that is why it was creating issue. I am using autoTableHtmlToJson() now, Can we fetch color like addHTML() in this method. actually I wants to show the colors in pdf like

But I am getting only text as

I am having this same problem however, I am using angular 4.3.5 & webpack.
When using:
import * as jsPDF from 'jspdf';
import 'jspdf-autotable'
I still get the error: Property 'autoTable' does not exist on type jsPDF
Any ideas how to get this functioning?
I have the same issue with Angular 5 & Webpack.
same here, any possible update on this issue soon ?
Same problem here, i'm use 1.1.31
Any update on this facing same with angular 5 and webpack and "jspdf": "^1.4.1", "jspdf-autotable": "^2.3.5"
I have the same issue with Angular 10
instead of doc.autoTable, For angular, you can use, autoTable(doc, { html: '#html-table-id',startY: 30, });
" You can also use the exported autoTable method. This works better with typescript and alternative jsPDF versions.
import jsPDF from 'jspdf' // import jsPDF = require('jspdf') // // typescript without esModuleInterop flag // import jsPDF from 'yworks-pdf' // using yworks fork // import jsPDF from 'jspdf/dist/jspdf.node.debug' // for nodejs import autoTable from 'jspdf-autotable'
const doc = new jsPDF() autoTable(doc, { html: '#my-table' }) doc.save('table.pdf') " The above is from the link https://github.com/simonbengtsson/jsPDF-AutoTable#installation
but I am not sure how to get the lastAutoTable.finalY position in typescript.
instead of doc.autoTable, For angular, you can use, autoTable(doc, { html: '#html-table-id',startY: 30, });
" You can also use the exported autoTable method. This works better with typescript and alternative jsPDF versions.
import jsPDF from 'jspdf' // import jsPDF = require('jspdf') // // typescript without esModuleInterop flag // import jsPDF from 'yworks-pdf' // using yworks fork // import jsPDF from 'jspdf/dist/jspdf.node.debug' // for nodejs import autoTable from 'jspdf-autotable'
const doc = new jsPDF() autoTable(doc, { html: '#my-table' }) doc.save('table.pdf') " The above is from the link https://github.com/simonbengtsson/jsPDF-AutoTable#installation
but I am not sure how to get the lastAutoTable.finalY position in typescript.
@ashgrey91 you can just convert doc to an any type like so (doc as any).lastAutoTable. Not ideal, but it'll get it working.
assuming you have @types/jspdf installed...
import { jsPDF } from 'jspdf';
import 'jspdf-autotable';
import { UserOptions } from 'jspdf-autotable';
interface jsPDFCustom extends jsPDF {
autoTable: (options: UserOptions) => void;
}
const doc = new jsPDF() as jsPDFCustom;