diff options
author | Hakim El Hattab <hakim.elhattab@gmail.com> | 2017-04-07 09:42:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-07 09:42:24 +0200 |
commit | 8ec5e00062e13cb2dff6750d5ba152567af30653 (patch) | |
tree | 742956547bf50b7fbc321e4fe49722f7dcd08e83 /plugin | |
parent | 1babc8d31c4964407c8cda1270c195866cac5429 (diff) | |
parent | 9a7c7ce93a530cfb8bb85e0670b1ffd171ccbba4 (diff) | |
download | perl-software-in-gnu-guix-8ec5e00062e13cb2dff6750d5ba152567af30653.tar perl-software-in-gnu-guix-8ec5e00062e13cb2dff6750d5ba152567af30653.tar.gz |
Merge pull request #1843 from riezebosch/pdf-print-callback
print-pdf using callback iso timer
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/print-pdf/print-pdf.js | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/plugin/print-pdf/print-pdf.js b/plugin/print-pdf/print-pdf.js index d1c3251..9ffc261 100644 --- a/plugin/print-pdf/print-pdf.js +++ b/plugin/print-pdf/print-pdf.js @@ -6,6 +6,7 @@ * * @author Manuel Bieh (https://github.com/manuelbieh) * @author Hakim El Hattab (https://github.com/hakimel) + * @author Manuel Riezebosch (https://github.com/riezebosch) */ // html2pdf.js @@ -21,11 +22,11 @@ if( outputFile.match( /\.pdf$/gi ) === null ) { outputFile += '.pdf'; } -console.log( 'Export PDF: Reading reveal.js config [1/3]' ); +console.log( 'Export PDF: Reading reveal.js config [1/4]' ); probePage.open( inputFile, function( status ) { - console.log( 'Export PDF: Preparing print layout [2/3]' ); + console.log( 'Export PDF: Preparing print layout [2/4]' ); var config = probePage.evaluate( function() { return Reveal.getConfig(); @@ -40,14 +41,22 @@ probePage.open( inputFile, function( status ) { }; printPage.open( inputFile, function( status ) { - window.setTimeout( function() { - console.log( 'Export PDF: Writing file [3/3]' ); + console.log( 'Export PDF: Preparing pdf [3/4]') + printPage.evaluate(function() { + Reveal.isReady() ? window.callPhantom() : Reveal.addEventListener( 'pdf-ready', window.callPhantom ); + }); + } ); + + printPage.onCallback = function(data) { + // For some reason we need to "jump the queue" for syntax highlighting to work. + // See: http://stackoverflow.com/a/3580132/129269 + setTimeout(function() { + console.log( 'Export PDF: Writing file [4/4]' ); printPage.render( outputFile ); console.log( 'Export PDF: Finished successfully!' ); phantom.exit(); - }, 1000 ); - } ); - + }, 0); + }; } else { @@ -55,7 +64,6 @@ probePage.open( inputFile, function( status ) { phantom.exit(1); } - } ); |