admin管理员组

文章数量:1277901

Is there a way to specify a callback function for the pdfMake's createPdf function? I have a large vfs_fonts.js file and that's why my export is slow.

Is there a way to specify a callback function for the pdfMake's createPdf function? I have a large vfs_fonts.js file and that's why my export is slow.

Share Improve this question asked Nov 30, 2015 at 14:59 IstvánIstván 5,12710 gold badges40 silver badges67 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

There is a callback function getDataUrl:

this.getDataUrl(function(result) {
    win.location.href = result;
});

This function is used by the open, save, and print functions that e built in. You can see their source here: https://github./bpampuch/pdfmake/blob/81de2c6a97ffb102f8c8c86ea9d7adf97e65976e/src/browser-extensions/pdfMake.js#L50

Using those functions, you should be able to build your own callback that does what you need.

You can use getDataUrl with something like

pdfMake.createPdf(docDefinition).getDataUrl(function(url) { alert('your pdf is done'); });

You would of course want more than that since you want to give them a way to do something with the pleted PDF.

To add a callback after the download is done:

pdfMake.createPdf(docDefinition).download('file.pdf', function() { alert('your pdf is done'); });

本文标签: javascriptpdfMake callback when export is finishedStack Overflow