aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHakim El Hattab <hakim.elhattab@gmail.com>2013-01-10 09:38:08 -0500
committerHakim El Hattab <hakim.elhattab@gmail.com>2013-01-10 09:38:31 -0500
commit17622052a03cf36232fcd57094051bf4080c4eb7 (patch)
treeb5b0bc66282c136e4709bd94a92fc5c4860ececb /plugin
parent5f2a875ec7702d5062aac44c5d9645ef300318c6 (diff)
parent5868becf84ee9983360882dcb9178c9970286639 (diff)
downloadfosdem-2018-presentation-17622052a03cf36232fcd57094051bf4080c4eb7.tar
fosdem-2018-presentation-17622052a03cf36232fcd57094051bf4080c4eb7.tar.gz
merge in phantomjs script for printing pdf (#276)
Diffstat (limited to 'plugin')
-rw-r--r--plugin/print-pdf/print-pdf.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugin/print-pdf/print-pdf.js b/plugin/print-pdf/print-pdf.js
new file mode 100644
index 0000000..8533137
--- /dev/null
+++ b/plugin/print-pdf/print-pdf.js
@@ -0,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();
+} ); \ No newline at end of file