Created
June 24, 2013 23:21
-
-
Save philfreo/5854629 to your computer and use it in GitHub Desktop.
PhantomJS: generate PDF to stdout from HTML in stdin. Example: echo "<b>test</b>" | phantomjs makepdf.js > test.pdf && open test.pdf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page = require('webpage').create(), | |
fs = require('fs'); | |
page.viewportSize = { width: 600, height: 600 }; | |
page.paperSize = { format: 'Letter', orientation: 'portrait', margin: '1cm' }; | |
page.content = fs.read('/dev/stdin'); | |
window.setTimeout(function() { | |
page.render('/dev/stdout', { format: 'pdf' }); | |
phantom.exit(); | |
}, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Broken on Linux due to: ariya/phantomjs#12780