summaryrefslogtreecommitdiffhomepage
path: root/plugin/print-pdf/print-pdf.js
diff options
context:
space:
mode:
authorDavid Banham2013-03-08 10:29:54 +1100
committerDavid Banham2013-03-08 10:29:54 +1100
commit61c229a4f969a0720085c2710f8a7cfd8a12b4a6 (patch)
tree637eeedce43c63a6aa004d566944ad791b984e7d /plugin/print-pdf/print-pdf.js
parent26d5febd7f24223900aa50d24d35e610c7c8a334 (diff)
parent7081f901da553206f746c40c4a0c1b5773697cf2 (diff)
Merge branch 'master' of https://github.com/hakimel/reveal.js
Conflicts: README.md index.html js/reveal.js package.json plugin/speakernotes/client.js
Diffstat (limited to 'plugin/print-pdf/print-pdf.js')
-rw-r--r--plugin/print-pdf/print-pdf.js39
1 files changed, 39 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..2b1d691
--- /dev/null
+++ b/plugin/print-pdf/print-pdf.js
@@ -0,0 +1,39 @@
+/**
+ * phantomjs script for printing presentations to PDF.
+ *
+ * Example:
+ * phantomjs print-pdf.js "http://lab.hakim.se/reveal-js?print-pdf" reveal-demo.pdf
+ *
+ * By Manuel Bieh (https://github.com/manuelbieh)
+ */
+
+// 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