The following worked for me in Angular 11, jsPDF 2.3.1, jspdf-autotable 3.5.14:
import jsPDF from 'jspdf'
import autoTable from 'jspdf-autotable'
public printTable() {
const doc = new jsPDF('l', 'mm', 'a4');
const head = [['ID', 'Country', 'Index', 'Capital']]
const data = [
[1, 'Finland', 7.632, 'Helsinki'],
[2, 'Norway', 7.594, 'Oslo'],
[3, 'Denmark', 7.555, 'Copenhagen'],
[4, 'Iceland', 7.495, 'Reykjavík'],
[5, 'Switzerland', 7.487, 'Bern'],
[9, 'Sweden', 7.314, 'Stockholm'],
[73, 'Belarus', 5.483, 'Minsk'],
]
autoTable(doc, {
head: head,
body: data,
didDrawCell: (data) => { },
});
doc.save('table.pdf');
}
Answer from John Chandler on Stack Overflow Top answer 1 of 7
14
The following worked for me in Angular 11, jsPDF 2.3.1, jspdf-autotable 3.5.14:
import jsPDF from 'jspdf'
import autoTable from 'jspdf-autotable'
public printTable() {
const doc = new jsPDF('l', 'mm', 'a4');
const head = [['ID', 'Country', 'Index', 'Capital']]
const data = [
[1, 'Finland', 7.632, 'Helsinki'],
[2, 'Norway', 7.594, 'Oslo'],
[3, 'Denmark', 7.555, 'Copenhagen'],
[4, 'Iceland', 7.495, 'Reykjavík'],
[5, 'Switzerland', 7.487, 'Bern'],
[9, 'Sweden', 7.314, 'Stockholm'],
[73, 'Belarus', 5.483, 'Minsk'],
]
autoTable(doc, {
head: head,
body: data,
didDrawCell: (data) => { },
});
doc.save('table.pdf');
}
2 of 7
6
I got the answer:
No need to import jspdf or jspdf-autotable in component.ts file.
component.ts:
import { Component, Input, OnInit, Inject } from '@angular/core';
declare let jsPDF;
In my case
var doc = new jsPDF('l', 'mm', [305, 250]);
var options1 = {
padding: 50
};
doc.addHTML($('#riskdate_heading'),0,10,options1 ,() => {
doc.addHTML($('#risktitle'),0,30,options1, () => {
var res = doc.autoTableHtmlToJson(document.getElementById("riskTable"));
var header = function(data) {
doc.setFontSize(18);
doc.setTextColor(40);
doc.setFontStyle('normal');
};
var riskoptions = {
tableWidth: 'auto',
addPageContent: header,
margin: { top: 10, horizontal: 7 },
startY: 50,
columnStyles: {0: {columnWidth: 'wrap'}}
};
doc.autoTable(res.columns, res.data, riskoptions);
doc.save("table.pdf");
});
});
GitHub
github.com › simonbengtsson › jsPDF-AutoTable › issues › 707
not compatible with jsPDF 2.0.0 - Property 'autoTable' does not exist on type 'jsPDF' · Issue #707 · simonbengtsson/jsPDF-AutoTable
May 31, 2020 - Hello, I tried to use jsPDF-AutoTable with jsPDF 2.0.0 but I cant find the way to solve the following compile error: Property 'autoTable' does not exist on type 'jsPDF' ` import jsPDF from 'jspdf'; import 'jspdf-autotable'; ... const doc...
Published Aug 15, 2020
npm
npmjs.com › package › jspdf-autotable
jspdf-autotable - npm
<script src="jspdf.min.js"></script> <script src="jspdf.plugin.autotable.min.js"></script> <script> const doc = new jsPDF() doc.autoTable({ html: '#my-table' }) doc.save('table.pdf') </script> Checkout more examples in examples.js which is also the source code for the demo documents. Below is a list of all options supported in the plugin. All of them are used in the examples. The only thing required is either the html or body option. If you want more control over the columns you can specify the columns property.
» npm install jspdf-autotable
Published Feb 26, 2025
Version 5.0.2
Author Simon Bengtsson
GitHub
github.com › simonbengtsson › jsPDF-AutoTable › issues › 324
autoTable does not exist on type jsPDF · Issue #324 · simonbengtsson/jsPDF-AutoTable
February 5, 2018 - dowloadPDF() { let doc = new jsPDF('p', 'pt'); let columns = [ {title: "ID", dataKey: "id"}, {title: "Name", dataKey: "name"}, {title: "Country", dataKey: "country"}, ]; let rows = [ {"id": 1, "name": "Shaw", "country": "Tanzania"}, {"id": 2, "name": "Nelson", "country": "Kazakhstan"}, {"id": 3, "name": "Garcia", "country": "Madagascar"}, ]; // Error ======================== doc.autoTable(columns, rows); doc.save('teste.pdf'); }
Published Feb 05, 2018
Lightrun
lightrun.com › answers › simonbengtsson-jspdf-autotable--property-autotable-does-not-exist-on-type-jspdf
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? ... 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.
Netlify
answers.netlify.com › support
jspdf-autoTable Library only does not work in deployment - Support - Netlify Support Forums
May 31, 2023 - I have a problem importing the jspdf-autoTable library, when working from localhost it works correctly but when uploading the page it tells me react_devtools_backend_compact.js:2367 The data should be an object or array, is: undefined. My site name is: https://cerimonial-pr.netlify.app/
Lightrun
lightrun.com › answers › simonbengtsson-jspdf-autotable-not-compatible-with-jspdf-200---property-autotable-does-not-exist-on-type-jspdf
not compatible with jsPDF 2.0.0 - Property 'autoTable' does not exist on type 'jsPDF'
As an alternative, you could create an interface wrapping the autoTable plugin. This effectively does the same, its just (imo) prettier: import { jsPDF } from "jspdf"; import 'jspdf-autotable'; import { UserOptions } from 'jspdf-autotable'; ...
GitHub
github.com › simonbengtsson › jsPDF-AutoTable › issues › 677
doc.autoTable Doesn't work · Issue #677 · simonbengtsson/jsPDF-AutoTable
any Property 'autoTable' does not exist on type 'jsPDF'. I have seen a couple of solutions to address this, but I want a proper solution not like declare var jsPDF: any; hack. Thanks.!
Published Jun 17, 2020
Author donqq
Angularfix
angularfix.com › 2022 › 03 › property-does-not-exist-on-type-jspdf.html
Property 'autoTable' does not exist on type jsPDF ~ angularfix
import * as jsPDF from 'jspdf'; import * as autoTable from 'jspdf-autotable';
GitHub
github.com › simonbengtsson › jsPDF-AutoTable › issues › 728
lastAutoTable property in TypeScript · Issue #728 · simonbengtsson/jsPDF-AutoTable
June 27, 2020 - I'm using the autotable exported method as it says in the docs ( import autoTable from 'jspdf-autotable'; ) and creating my table with autoTable(doc, options); I need to get the final Y of the last autotable for multiple tables. With doc.lastAutoTable.finalY it says that lastAutoTable property does not exist on type jsPDF.
Published Sep 30, 2020
CopyProgramming
copyprogramming.com › howto › property-autotable-does-not-exist-on-type-jspdf
Type jspdf lacks property autotable - Javascript
May 11, 2023 - The reason for this error is that Typescript is a strongly typed language, and lastAutoTable is not defined in the index.d.ts file, which is located under the jsPdf node module. For Angular 11, jsPDF 2.3.1, and jspdf-autotable 3.5.14, the first solution worked for me.
Githubhot
githubhot.com › repo › simonbengtsson › jsPDF-AutoTable › issues › 707
not compatible with jsPDF 2.0.0 - Property 'autoTable' does not exist on type 'jsPDF' - bytemeta
(doc as jsPDF & { autoTable: autoTable }).autoTable({ head: [columnsTitles], body: this.source as RowInput[], (...) }); ... As an alternative, you could create an interface wrapping the autoTable plugin.
bleepCoder
bleepcoder.com › jspdf-autotable › 362200513 › property-autotable-does-not-exist-on-type-jspdf
jsPDF-AutoTable 🚀 - Property 'autoTable' does not exist on type 'jsPDF' | bleepcoder.com
I think this error is caused because we are creating a new object from the jsPDF and we're trying to access the autoTable method by using that object and JsPdf does not own this property | method, I think the solution here is to create an object from jspdf-autotable library itself, but I don't know how to import this lib in angular 7! thanks, ... Hi @Furqanaa, I working in Angular 8 and I have the same error, in DEV environment that solution work properly but when I try compile for PROD environment I get the same problem during the compilation process · "Property 'autoTable' does not exist on type 'jsPDF'."
Itecnote
itecnote.com › tecnote › javascript-property-autotable-does-not-exist-on-type-jspdf
Javascript – Property 'autoTable' does not exist on type jsPDF
Skip to content · React-native – React Native Error: “Animated.event now requires a second argument for options” · Python – keep on getting “x and y must have same first dimension, but have shapes (100,) and (1, 100)” · Java – Docker WARNING: Published ports are discarded when ...