doc.save() throwing error with jspdf

Owen Davey picture Owen Davey · Dec 3, 2013 · Viewed 31.3k times · Source

When I try and use the save() function for jsPDF it's throwing the following error:

ReferenceError: saveAs is not defined

I'm just trying a very simple example:

var doc = new jsPDF();
doc.text(20, 20, 'Hello world!');
doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
doc.addPage();
doc.text(20, 20, 'Do you like that?');

doc.save('test.pdf');

Anyone have any ideas what's wrong?

Answer

Owen Davey picture Owen Davey · Dec 3, 2013

Found out what the issue was. The saveAs function is part of FileSaver.js so I just needed to include this and everything worked.