Uncaught TypeError
Using google chrome I tried to run he script and recieved the following error pointing at line 12 of jspd.plugin.autotable.js
Uncaught TypeError: Cannot read property 'events' of undefined. And because of this the autoTable function in unrecognised. How do I fix this?
Sounds strange, it would indicate that the API instance is not set. Could you post the code you are using?
I tried using my own code but that didn't work so i'm just trying it with your example to see if it works. The code
$(document).on("click", "#PDF", function () {
var columns = [
{title: "ID", key: "id"},
{title: "Name", key: "name"},
{title: "Country", key: "country"},
{title: "Email", key: "email"}
];
var data = [
{"id": 1, "name": "Shaw", "country": "Tanzania", "email": "[email protected]"},
{"id": 2, "name": "Nelson", "country": "Kazakhstan", "email": "[email protected]"},
{"id": 3, "name": "Garcia", "country": "Madagascar", "email": "[email protected]"}
];
var doc = new jsPDF('p', 'pt');
doc.autoTable(columns, data, {});
doc.save('table.pdf');
});
Strange! That code works for me. Check out this fiddle: https://jsfiddle.net/someatoms/buLugtcc/ Code you post the html as well?
Can't seem to fix this error:
Uncaught TypeError: undefined is not a functionjspdf.plugin.autotable.js:39 defaultOptions.renderHeaderCelljspdf.plugin.autotable.js:233 (anonymous function)jspdf.plugin.autotable.js:230 printHeaderjspdf.plugin.autotable.js:88 API.autoTable(index):1204 (anonymous function)jquery-1.11.2.min.js:3 m.event.dispatchjquery-1.11.2.min.js:3 m.event.add.r.handle
On this line :
y += settings.lineHeight / 2 + doc.internal.getLineHeight() / 2;
It seems to be a problem with your setup. Can you try to reproduce the issue in a jsfiddle or send me your entire html and js code?
I can't create it on Fiddle, how do I send it to you?
Add it here.
https://jsfiddle.net/jdr430/Lqgm0g77/
In the jsFiddle you need to include the jspdf before the autotable plugin, like in the jsfiddle I posted. I did the same error at first...
Sorry about this I just realised the order was wrong. It now works fine I needed to place the debug before autotable. Thanks you can close this, sorry for time-wasting
No worries, let me know if run into other issues!
Hi, I used following code and I am getting error EXCEPTION: Error in ./AppComponent class AppComponent - inline template:6:12 caused by: this.internal.getCurrentPageInfo is not a function
I tried following code , please suggest what I missed
import { Component } from '@angular/core';
declare let jsPDF:any;
@Component({
selector: 'my-app',
template:
<button (click)="trythis()">click</button>
})
export class AppComponent{
cols:any=[
{headerName: "NAME", field: "name", width: 250},
{headerName: "AGE", field: "age", width: 250},
{headerName: "GENDER", field: "gender", width: 250}
];
rows:any=[
{name: "Geller", age: 30, gender: "Male"},
{name: "Geller", age: 28, gender: "Female"},
{name: "Tribbiani", age: 29, gender: "Male"},
{name: "Bing", age: 30, gender: "Male"},
{name: "Green", age: 28, gender: "Female"},
{name: "Buffay", age: 29, gender: "Female"}
];
trythis() {
var doc = new jsPDF('p', 'pt');
doc.autoTable(this.cols, this.rows);
doc.save("table.pdf")
}
}