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?
Found out what the issue was. The saveAs function is part of FileSaver.js so I just needed to include this and everything worked.
I don't have enough to comment yet, so I'm adding this as an answer... saveAs()
is a w3c interface. If adding FileSaver fixed your issue, that means you were using an old browser; FileSaver.js is used as a shim for jsPDF to support older browsers that don't have that function natively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With