Promise or callback after calling `.save(filename)` or `.output('save', filename)`
Is there a way to fire a callback after the save action is complete? I'd like to only close a modal window after the file is "downloaded" so I need some way to act once it is complete.
I did see there is a PubSub class, how does that fit in to this library?
+1
+1
+1
+1
Yeah that'd be great
+1
Any update here?
Would be neat to have this function. We would ideally want to redirect to another page only after the file has been created and saved to server as to avoid trying to access the file before it has been created.
Although pull request by @raymondelferink shows as closed, jspdf.debug.js shows nothing related to a callback function for API.save can anyone confirm that a callback exists?
Apparently there is no option to add a callback,, can anyone confirm this ?
Thanks...
@carlosalarconb Please see comment I am posting on PR #1159
added option returnPromise to save-method. will be part of next release.
var doc = new jsPDF(); doc.save('test.pdf', {returnPromise: true});
Instead use {usePromise: true}, you should use {returnPromise: true}.
@matheusgomes1
You are right. While in development I changed it to returnPromise. Thank you. I edited my previous answer. ;)
For anyone else not super up to speed on promise logic/syntax, here's how I leveraged this (awesome) returnPromise bit:
pdf.save("myfile.pdf", {returnPromise:true}).then(alert('PDF render all done!'));