question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught ReferenceError: jsPDF is not defined

See original GitHub issue

I’ve installed jsPDF (v0.91) and jspdf-autotable using NPM. This is my package.json:

 "dependencies": {
    "jspdf": "git://github.com/pavestru/jsPDF.git#v0.9.1",
    "jspdf-autotable": "^2.0.22",
  }

I’m using a specific old version of jsPDF since the latest versions don’t work with NPM (see here for details).

The output of npm install with that package.json gives:

├── jspdf@0.9.1 (git://github.com/pavestru/jsPDF.git#217c44d40cef6c5d567aa6db8e2f0d548e89c387)
└─┬ jspdf-autotable@2.0.22
  └── jspdf@1.2.61

It looks as if jspdf-autotable installed its own version of jspdf (v1.2.61). Is that correct? Anyhow, my code (livescript):

jsPDF = require 'jspdf'
pdf = new jsPDF()
pdf.autoTable(columns, rows)

But after bundling everything using webpack and running my application I get:

jspdf.plugin.autotable.js:10 Uncaught ReferenceError: jsPDF is not defined. @jspdf.plugin.autotable.js:10

What am I doing wrong or is there something wrong with jspdf-autotable?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
simonbengtssoncommented, Mar 18, 2016

Released a new version now 2.0.24 which I have tested works with webpack and version 0.9.1 and 0.9.2 of jspdf. I tested by running webpack app.js bundle.js with the following code:

// app.js
var jsPDF = require('jspdf');
require('jspdf-autotable');

var doc = new jsPDF('p', 'pt');

var columns = ["ID", "Name", "Age", "City"];
var data = [
    [1, "Jonatan", 25, "Gothenburg"],
    [2, "Simon", 23, "Gothenburg"],
    [3, "Hanna", 21, "Stockholm"]
];

doc.autoTable(columns, data);
doc.save("table.pdf");

I realize that this is not the webpack config you used, but at least there should be now issues with jspdf-autotable anymore. The way you are loading npm packages from package.json looks kind of like a hack to me? You might want to look into code splitting instead of manually splitting into vendor and app bundles?

1reaction
ernestocasanovacommented, Sep 26, 2019

I’m using jsPDF in Angular 8 with autotable, in this view requires custom the Table in DOM, and I tried all options possible…

Versions: “jspdf”: “^1.5.3”, “jspdf-autotable”: “^3.2.4”,

Any solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: jsPDF is not defined - Stack Overflow
Can someone explain what this line does. I presume that window.jsPDF becomes a new property of the window obj, but what is window.jspdf.jsPDF?...
Read more >
Uncaught ReferenceError: jsPDF is not defined #3079 - GitHub
Unable to generate a PDF from a simple HTML div object. The function jsPDF cannot be found. The error that I get is...
Read more >
HTML : Uncaught ReferenceError: jsPDF is not defined
HTML : Uncaught ReferenceError : jsPDF is not defined [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] HTML : Uncaught ...
Read more >
Javascript – jsPDF is not defined error in html project - iTecNote
I am implementing jsPdf example and have sample html project in which i included jquery ... Uncaught ReferenceError: jsPDF is not defined at...
Read more >
Uncaught ReferenceError: jsPDF is not defined - Code Grepper
uncaught referenceerror: jspdf is not defined · Oops, You will need to install Grepper and log-in to perform this action.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found