2013-01-10 15:38:08 +01:00
|
|
|
/**
|
|
|
|
* phantomjs script for printing presentations to PDF.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* phantomjs print-pdf.js "http://lab.hakim.se/reveal-js?print-pdf" reveal-demo.pdf
|
2013-01-10 15:40:03 +01:00
|
|
|
*
|
|
|
|
* By Manuel Bieh (https://github.com/manuelbieh)
|
2013-01-10 15:38:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
// html2pdf.js
|
|
|
|
var page = new WebPage();
|
|
|
|
var system = require( 'system' );
|
|
|
|
|
2013-06-19 03:55:01 +02:00
|
|
|
page.viewportSize = {
|
|
|
|
width: 1024,
|
|
|
|
height: 768
|
|
|
|
};
|
|
|
|
|
2013-01-10 15:38:08 +01:00
|
|
|
page.paperSize = {
|
2013-06-19 03:55:01 +02:00
|
|
|
format: 'letter',
|
2013-01-10 15:38:08 +01:00
|
|
|
orientation: 'landscape',
|
|
|
|
margin: {
|
|
|
|
left: '0',
|
|
|
|
right: '0',
|
|
|
|
top: '0',
|
|
|
|
bottom: '0'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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();
|
2013-06-19 03:55:01 +02:00
|
|
|
} );
|
|
|
|
|