Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

461
Views
JsPDF Uncaught ReferenceError: jsPDF is not defined"

I am trying to save a div as a PDF using jsPDF. Here is my fiddle: https://jsfiddle.net/waleedbinahmed/bfj6qktv/11/ and here is a fiddle that someone else has uploaded: https://jsfiddle.net/waleedbinahmed/8s4qvu27/

The second fiddle is working fine.

I have tried to mimic the second fiddle i.e. including the same js and Jquery libraries. But on my fiddle, I am getting this error "Uncaught ReferenceError: jsPDF is not defined".

I don't know what I am missing on my fiddle that is causing the issue. Please help me out with what needs to be updated with respect to the second fiddle so that I can save a div a PDF.

JS library: https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.debug.js

Here is my code: HTML:

<div id="content">
  <h3>Hello, this is a H3 tag</h3>

  <p>A paragraph</p>
</div>
<div id="editor"></div>
<button onclick="javascript:createPdf()" id="cmd">generate PDF</button>

Javascript:

function createPdf() {
     var doc = new jsPDF();
    
      source = $('#content')[0];
    
      specialElementHandlers = {
        '#editor': function(element, renderer) {
          return true
        }
      };
    
      doc.fromHTML(
        source,
        15,
        15, {
          'width': 170,
          'elementHandlers': specialElementHandlers
        }
      );
      doc.save('sample-file.pdf')
    }

thanks.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

i did watch to your fiddle (the first one that was not working correctly), and just paste js library from the correct fiddle

and its working. sounds like your imported library doesn't work. and also the working fiddle has a jquery 3.4.1 implemented

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!