I use PhantomJS as a tool for PDF rendering. Here is the code snippet:
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit();
} else {
window.setTimeout(function () {
//page.render(output);
page.render('/dev/stdout', { format: 'pdf' })
phantom.exit();
}, 30000);
}
});
As you can see, render()
method will be called after 30 seconds in case of success respond after open()
method.
Is there a possibility to use some callback when this pdf-file is really created, rendered and ready to be downloaded, to provide a link to user not after 30 seconds, but exactly after the file created?