From: Hakim El Hattab Date: Thu, 10 Jan 2013 14:38:08 +0000 (-0500) Subject: merge in phantomjs script for printing pdf (#276) X-Git-Tag: 2.2.0~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=17622052a03cf36232fcd57094051bf4080c4eb7;p=reveal.js.git merge in phantomjs script for printing pdf (#276) --- 17622052a03cf36232fcd57094051bf4080c4eb7 diff --cc plugin/print-pdf/print-pdf.js index 0000000,0000000..8533137 new file mode 100644 --- /dev/null +++ b/plugin/print-pdf/print-pdf.js @@@ -1,0 -1,0 +1,38 @@@ ++/** ++ * phantomjs script for printing presentations to PDF. ++ * ++ * Example: ++ * ++ * phantomjs print-pdf.js "http://lab.hakim.se/reveal-js?print-pdf" reveal-demo.pdf ++ */ ++ ++// html2pdf.js ++var page = new WebPage(); ++var system = require( 'system' ); ++ ++page.paperSize = { ++ format: 'A4', ++ orientation: 'landscape', ++ margin: { ++ left: '0', ++ right: '0', ++ top: '0', ++ bottom: '0' ++ } ++}; ++page.zoomFactor = 1.5; ++ ++var revealFile = system.args[1] || 'index.html?print-pdf'; ++var slideFile = system.args[2] || 'slides.pdf'; ++ ++if( slideFile.match( /\.pdf$/gi ) === null ) { ++ slideFile += '.pdf'; ++} ++ ++console.log( 'Printing PDF...' ); ++ ++page.open( revealFile, function( status ) { ++ console.log( 'Printed succesfully' ); ++ page.render( slideFile ); ++ phantom.exit(); ++} );