Skip to content

Promise or callback after calling .save(filename) or .output('save', filename) #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jimbuck opened this issue Jul 2, 2015 · 14 comments
Closed

Comments

@jimbuck
Copy link

jimbuck commented Jul 2, 2015

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?

@gustavolira
Copy link

+1

3 similar comments
@RobsonMathias
Copy link

+1

@fabianoroberto
Copy link

+1

@domagojhack
Copy link

+1

@MrRio
Copy link
Member

MrRio commented Sep 30, 2016

Yeah that'd be great

@MrRio MrRio closed this as completed Sep 30, 2016
@MrRio MrRio reopened this Sep 30, 2016
@uramonz
Copy link

uramonz commented Oct 6, 2016

+1

Any update here?

@hitolonen
Copy link

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.

@ankithkonda
Copy link

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?

@carlosalarconb
Copy link

Apparently there is no option to add a callback,, can anyone confirm this ?

Thanks...

@Flamenco
Copy link
Contributor

Flamenco commented Apr 26, 2017

@carlosalarconb Please see comment I am posting on PR #1159

@Uzlopak
Copy link
Collaborator

Uzlopak commented Dec 4, 2018

added option returnPromise to save-method. will be part of next release.

var doc = new jsPDF();
doc.save('test.pdf', {returnPromise: true});

@Uzlopak Uzlopak closed this as completed Dec 4, 2018
@matheusgomes1
Copy link

Instead use {usePromise: true}, you should use {returnPromise: true}.

@Uzlopak
Copy link
Collaborator

Uzlopak commented Jan 17, 2019

@matheusgomes1

You are right. While in development I changed it to returnPromise. Thank you. I edited my previous answer. ;)

@cemerson
Copy link

cemerson commented Jun 25, 2019

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!'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests