Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
| Download
Project: KOB1
Views: 16973/**1* phantomjs script for printing presentations to PDF.2*3* Example:4* phantomjs print-pdf.js "http://revealjs.com?print-pdf" reveal-demo.pdf5*6* @author Manuel Bieh (https://github.com/manuelbieh)7* @author Hakim El Hattab (https://github.com/hakimel)8* @author Manuel Riezebosch (https://github.com/riezebosch)9*/1011// html2pdf.js12var system = require( 'system' );1314var probePage = new WebPage();15var printPage = new WebPage();1617var inputFile = system.args[1] || 'index.html?print-pdf';18var outputFile = system.args[2] || 'slides.pdf';1920if( outputFile.match( /\.pdf$/gi ) === null ) {21outputFile += '.pdf';22}2324console.log( 'Export PDF: Reading reveal.js config [1/4]' );2526probePage.open( inputFile, function( status ) {2728console.log( 'Export PDF: Preparing print layout [2/4]' );2930var config = probePage.evaluate( function() {31return Reveal.getConfig();32} );3334if( config ) {3536printPage.paperSize = {37width: Math.floor( config.width * ( 1 + config.margin ) ),38height: Math.floor( config.height * ( 1 + config.margin ) ),39border: 040};4142printPage.open( inputFile, function( status ) {43console.log( 'Export PDF: Preparing pdf [3/4]')44printPage.evaluate(function() {45Reveal.isReady() ? window.callPhantom() : Reveal.addEventListener( 'pdf-ready', window.callPhantom );46});47} );4849printPage.onCallback = function(data) {50// For some reason we need to "jump the queue" for syntax highlighting to work.51// See: http://stackoverflow.com/a/3580132/12926952setTimeout(function() {53console.log( 'Export PDF: Writing file [4/4]' );54printPage.render( outputFile );55console.log( 'Export PDF: Finished successfully!' );56phantom.exit();57}, 0);58};59}60else {6162console.log( 'Export PDF: Unable to read reveal.js config. Make sure the input address points to a reveal.js page.' );63phantom.exit(1);6465}66} );6768697071