aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2017-02-15 11:43:57 +0100
committerHakim El Hattab <hakim.elhattab@gmail.com>2017-02-15 11:43:57 +0100
commitfa70a7a5174b16b1b4e9ccaf3f36cbb082cc8051 (patch)
tree841bd22d57bb16e6435c05f36e593b7494442ab3 /plugin
parentbef8109506b3aa06d7835661ecd7ec3d35c7c6e0 (diff)
downloadperl-software-in-gnu-guix-fa70a7a5174b16b1b4e9ccaf3f36cbb082cc8051.tar
perl-software-in-gnu-guix-fa70a7a5174b16b1b4e9ccaf3f36cbb082cc8051.tar.gz
phantom export throws error if reveal.js isn't present
Diffstat (limited to 'plugin')
-rw-r--r--plugin/print-pdf/print-pdf.js38
1 files changed, 24 insertions, 14 deletions
diff --git a/plugin/print-pdf/print-pdf.js b/plugin/print-pdf/print-pdf.js
index c3c5d94..d1c3251 100644
--- a/plugin/print-pdf/print-pdf.js
+++ b/plugin/print-pdf/print-pdf.js
@@ -31,20 +31,30 @@ probePage.open( inputFile, function( status ) {
return Reveal.getConfig();
} );
- printPage.paperSize = {
- width: config.width * ( 1 + config.margin ),
- height: config.height * ( 1 + config.margin ),
- border: 0
- };
-
- printPage.open( inputFile, function( status ) {
- window.setTimeout( function() {
- console.log( 'Export PDF: Writing file [3/3]' );
- printPage.render( outputFile );
- console.log( 'Export PDF: Finished successfully!' );
- phantom.exit();
- }, 1000 );
- } );
+ if( config ) {
+
+ printPage.paperSize = {
+ width: Math.floor( config.width * ( 1 + config.margin ) ),
+ height: Math.floor( config.height * ( 1 + config.margin ) ),
+ border: 0
+ };
+
+ printPage.open( inputFile, function( status ) {
+ window.setTimeout( function() {
+ console.log( 'Export PDF: Writing file [3/3]' );
+ printPage.render( outputFile );
+ console.log( 'Export PDF: Finished successfully!' );
+ phantom.exit();
+ }, 1000 );
+ } );
+
+ }
+ else {
+
+ console.log( 'Export PDF: Unable to read reveal.js config. Make sure the input address points to a reveal.js page.' );
+ phantom.exit(1);
+
+ }
} );