how to use jsPDF and jspdf-autotable in angular 5
I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts):
"dependencies": {
...
"jspdf": "^1.3.5",
"jspdf-autotable": "^2.3.2"
...
}
My angular-cli.json is below (related parts):
"scripts": [
...
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
...
]
My component (related parts ):
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
It says:
[ts] Property 'autoTable' does not exist on type 'jsPDF'.
I tried to replace imports in my component with
// import * as jsPDF from 'jspdf';
// import 'jspdf-autotable';
declare var jsPDF: any;
then there is no compile time error but while running downloadPDF() function it says :
ERROR ReferenceError: jsPDF is not defined

add a comment |
I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts):
"dependencies": {
...
"jspdf": "^1.3.5",
"jspdf-autotable": "^2.3.2"
...
}
My angular-cli.json is below (related parts):
"scripts": [
...
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
...
]
My component (related parts ):
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
It says:
[ts] Property 'autoTable' does not exist on type 'jsPDF'.
I tried to replace imports in my component with
// import * as jsPDF from 'jspdf';
// import 'jspdf-autotable';
declare var jsPDF: any;
then there is no compile time error but while running downloadPDF() function it says :
ERROR ReferenceError: jsPDF is not defined

add a comment |
I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts):
"dependencies": {
...
"jspdf": "^1.3.5",
"jspdf-autotable": "^2.3.2"
...
}
My angular-cli.json is below (related parts):
"scripts": [
...
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
...
]
My component (related parts ):
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
It says:
[ts] Property 'autoTable' does not exist on type 'jsPDF'.
I tried to replace imports in my component with
// import * as jsPDF from 'jspdf';
// import 'jspdf-autotable';
declare var jsPDF: any;
then there is no compile time error but while running downloadPDF() function it says :
ERROR ReferenceError: jsPDF is not defined

I am trying to use jsPDF and jspdf-autotable in my Angular 5.2.0 project. My package.json is below (related parts):
"dependencies": {
...
"jspdf": "^1.3.5",
"jspdf-autotable": "^2.3.2"
...
}
My angular-cli.json is below (related parts):
"scripts": [
...
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
...
]
My component (related parts ):
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
It says:
[ts] Property 'autoTable' does not exist on type 'jsPDF'.
I tried to replace imports in my component with
// import * as jsPDF from 'jspdf';
// import 'jspdf-autotable';
declare var jsPDF: any;
then there is no compile time error but while running downloadPDF() function it says :
ERROR ReferenceError: jsPDF is not defined


edited Mar 23 '18 at 8:53
RIDVAN TANIK
asked Mar 23 '18 at 8:26
RIDVAN TANIKRIDVAN TANIK
2116
2116
add a comment |
add a comment |
7 Answers
7
active
oldest
votes
Is working for me Angular 5.
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just.
Forget about the following import.
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
Just use Before @Component:
declare var jsPDF: any;
Your component (related parts ):
declare var jsPDF: any;
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
1
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
add a comment |
First you have declared .js
files in styles
property in angular-cli.json
, you should add them to scripts
. In the configuration that you have, you should add your jspdf
scripts to scripts
in angular-cli.json
, So:
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
then you don't have to import any jspdf
to your component. declare var jsPdf: any
will be enough to use it.
1
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
add a comment |
In angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js"
],
In your project
import * as jsPdf from 'jspdf';
import 'jspdf-autotable';
This work for me
add a comment |
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just
declare var jsPDF: any;
Of course before working with jspdf-autotable one should install jspdf and for development @types/jspdf via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
add a comment |
If you could use declare var jsPDF: any; it is working for Chrome, IE and other browsers too, but it is not working for Firefox browser.
In this case, you could follow the below steps:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
and other parts remain same like:
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
So, it will defiantly work on all the browsers.
how simple it is :)
add a comment |
I solved this issue, first import the Jspdf import * as jsPDF from 'jspdf';
i'm used a codesmells tatic, copied the content of jspdf autotable and pasted inside
the jspdf.js, then works fine for me.
in the official site said you have to use //declare var jsPDF: any; // Important . it doesnt work in my case, try import * as jsPDF from 'jspdf'; instead.
in angular.json in scripts :
"./node_modules/jspdf/dist/jspdf.min.js",
"./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js",
add a comment |
I'm using angular 7, and just declare var jsPDF: any;
doesn't work to me. After some googling, the solution was:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
And of course, I installed the modules from npm and include them into the scripts array in angular.json. It works fine to me.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49445269%2fhow-to-use-jspdf-and-jspdf-autotable-in-angular-5%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
7 Answers
7
active
oldest
votes
7 Answers
7
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is working for me Angular 5.
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just.
Forget about the following import.
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
Just use Before @Component:
declare var jsPDF: any;
Your component (related parts ):
declare var jsPDF: any;
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
1
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
add a comment |
Is working for me Angular 5.
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just.
Forget about the following import.
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
Just use Before @Component:
declare var jsPDF: any;
Your component (related parts ):
declare var jsPDF: any;
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
1
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
add a comment |
Is working for me Angular 5.
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just.
Forget about the following import.
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
Just use Before @Component:
declare var jsPDF: any;
Your component (related parts ):
declare var jsPDF: any;
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
Is working for me Angular 5.
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just.
Forget about the following import.
import * as jsPDF from 'jspdf';
import 'jspdf-autotable';
Just use Before @Component:
declare var jsPDF: any;
Your component (related parts ):
declare var jsPDF: any;
@Component({
selector: "energy-login",
templateUrl: "./login.component.html",
styleUrls: ["./login.component.scss"]
})
export class MyComponent implements OnInit {
constructor() {}
ngOnInit() {}
downloadPDF() {
let columns = ["ID", "Name", "Country"];
let rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
let doc = new jsPDF('l', 'pt');
doc.autoTable(columns, rows); // typescript compile time error
doc.save('table.pdf');
}
}
answered Jul 24 '18 at 21:37
Alciomar HollandaAlciomar Hollanda
34036
34036
1
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
add a comment |
1
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
1
1
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
Thanks @Alciomar Hollanda, It help me a lot.
– Mohammad Ali
Sep 12 '18 at 5:30
add a comment |
First you have declared .js
files in styles
property in angular-cli.json
, you should add them to scripts
. In the configuration that you have, you should add your jspdf
scripts to scripts
in angular-cli.json
, So:
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
then you don't have to import any jspdf
to your component. declare var jsPdf: any
will be enough to use it.
1
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
add a comment |
First you have declared .js
files in styles
property in angular-cli.json
, you should add them to scripts
. In the configuration that you have, you should add your jspdf
scripts to scripts
in angular-cli.json
, So:
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
then you don't have to import any jspdf
to your component. declare var jsPdf: any
will be enough to use it.
1
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
add a comment |
First you have declared .js
files in styles
property in angular-cli.json
, you should add them to scripts
. In the configuration that you have, you should add your jspdf
scripts to scripts
in angular-cli.json
, So:
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
then you don't have to import any jspdf
to your component. declare var jsPdf: any
will be enough to use it.
First you have declared .js
files in styles
property in angular-cli.json
, you should add them to scripts
. In the configuration that you have, you should add your jspdf
scripts to scripts
in angular-cli.json
, So:
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
then you don't have to import any jspdf
to your component. declare var jsPdf: any
will be enough to use it.
edited Mar 23 '18 at 8:49
answered Mar 23 '18 at 8:38


EfeEfe
1,4301524
1,4301524
1
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
add a comment |
1
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
1
1
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
thank you. Your right .js files should be declared in scripts array, and I actually declared them in there - fixed it in the question. My previous attempt was installing dependencies via npm. That is why my dependencies object in package.json includes "jspdf": "^1.3.5", "jspdf-autotable": "^2.3.2" also devDependencies object includes "@types/jspdf": "^1.1.31". Anyway i solved my problem. Answering my question below.
– RIDVAN TANIK
Mar 23 '18 at 9:02
add a comment |
In angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js"
],
In your project
import * as jsPdf from 'jspdf';
import 'jspdf-autotable';
This work for me
add a comment |
In angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js"
],
In your project
import * as jsPdf from 'jspdf';
import 'jspdf-autotable';
This work for me
add a comment |
In angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js"
],
In your project
import * as jsPdf from 'jspdf';
import 'jspdf-autotable';
This work for me
In angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js"
],
In your project
import * as jsPdf from 'jspdf';
import 'jspdf-autotable';
This work for me
answered Mar 28 '18 at 2:52
JimJim
6611
6611
add a comment |
add a comment |
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just
declare var jsPDF: any;
Of course before working with jspdf-autotable one should install jspdf and for development @types/jspdf via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
add a comment |
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just
declare var jsPDF: any;
Of course before working with jspdf-autotable one should install jspdf and for development @types/jspdf via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
add a comment |
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just
declare var jsPDF: any;
Of course before working with jspdf-autotable one should install jspdf and for development @types/jspdf via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
To work with jspdf-autotable in angular 5, one must install jspdf and jspdf-autotable via npm
npm install jspdf-autotable --save
also add the jspdf and jspdf-autotable files to the scripts array in angular-cli.json
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
and in component never import jspdf or jspdf-autotable just
declare var jsPDF: any;
Of course before working with jspdf-autotable one should install jspdf and for development @types/jspdf via npm
npm install jspdf --save
npm install @types/jspdf --save-dev
answered Mar 23 '18 at 9:30
RIDVAN TANIKRIDVAN TANIK
2116
2116
add a comment |
add a comment |
If you could use declare var jsPDF: any; it is working for Chrome, IE and other browsers too, but it is not working for Firefox browser.
In this case, you could follow the below steps:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
and other parts remain same like:
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
So, it will defiantly work on all the browsers.
how simple it is :)
add a comment |
If you could use declare var jsPDF: any; it is working for Chrome, IE and other browsers too, but it is not working for Firefox browser.
In this case, you could follow the below steps:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
and other parts remain same like:
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
So, it will defiantly work on all the browsers.
how simple it is :)
add a comment |
If you could use declare var jsPDF: any; it is working for Chrome, IE and other browsers too, but it is not working for Firefox browser.
In this case, you could follow the below steps:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
and other parts remain same like:
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
So, it will defiantly work on all the browsers.
how simple it is :)
If you could use declare var jsPDF: any; it is working for Chrome, IE and other browsers too, but it is not working for Firefox browser.
In this case, you could follow the below steps:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
and other parts remain same like:
npm install jspdf --save
npm install @types/jspdf --save-dev
npm install jspdf-autotable --save
"scripts": [
"../node_modules/jspdf/dist/jspdf.min.js",
"../node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js"
],
So, it will defiantly work on all the browsers.
how simple it is :)
answered Mar 11 at 3:53
Rahul ChavanRahul Chavan
112
112
add a comment |
add a comment |
I solved this issue, first import the Jspdf import * as jsPDF from 'jspdf';
i'm used a codesmells tatic, copied the content of jspdf autotable and pasted inside
the jspdf.js, then works fine for me.
in the official site said you have to use //declare var jsPDF: any; // Important . it doesnt work in my case, try import * as jsPDF from 'jspdf'; instead.
in angular.json in scripts :
"./node_modules/jspdf/dist/jspdf.min.js",
"./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js",
add a comment |
I solved this issue, first import the Jspdf import * as jsPDF from 'jspdf';
i'm used a codesmells tatic, copied the content of jspdf autotable and pasted inside
the jspdf.js, then works fine for me.
in the official site said you have to use //declare var jsPDF: any; // Important . it doesnt work in my case, try import * as jsPDF from 'jspdf'; instead.
in angular.json in scripts :
"./node_modules/jspdf/dist/jspdf.min.js",
"./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js",
add a comment |
I solved this issue, first import the Jspdf import * as jsPDF from 'jspdf';
i'm used a codesmells tatic, copied the content of jspdf autotable and pasted inside
the jspdf.js, then works fine for me.
in the official site said you have to use //declare var jsPDF: any; // Important . it doesnt work in my case, try import * as jsPDF from 'jspdf'; instead.
in angular.json in scripts :
"./node_modules/jspdf/dist/jspdf.min.js",
"./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js",
I solved this issue, first import the Jspdf import * as jsPDF from 'jspdf';
i'm used a codesmells tatic, copied the content of jspdf autotable and pasted inside
the jspdf.js, then works fine for me.
in the official site said you have to use //declare var jsPDF: any; // Important . it doesnt work in my case, try import * as jsPDF from 'jspdf'; instead.
in angular.json in scripts :
"./node_modules/jspdf/dist/jspdf.min.js",
"./node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js",
answered Jan 3 at 0:52


gaston villafañegaston villafañe
1
1
add a comment |
add a comment |
I'm using angular 7, and just declare var jsPDF: any;
doesn't work to me. After some googling, the solution was:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
And of course, I installed the modules from npm and include them into the scripts array in angular.json. It works fine to me.
add a comment |
I'm using angular 7, and just declare var jsPDF: any;
doesn't work to me. After some googling, the solution was:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
And of course, I installed the modules from npm and include them into the scripts array in angular.json. It works fine to me.
add a comment |
I'm using angular 7, and just declare var jsPDF: any;
doesn't work to me. After some googling, the solution was:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
And of course, I installed the modules from npm and include them into the scripts array in angular.json. It works fine to me.
I'm using angular 7, and just declare var jsPDF: any;
doesn't work to me. After some googling, the solution was:
declare const require: any;
const jsPDF = require('jspdf');
require('jspdf-autotable');
And of course, I installed the modules from npm and include them into the scripts array in angular.json. It works fine to me.
answered Jan 23 at 17:25


André PachecoAndré Pacheco
396212
396212
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49445269%2fhow-to-use-jspdf-and-jspdf-autotable-in-angular-5%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown