Created
June 18, 2014 05:47
-
-
Save zacharyliu/495dcc12a19b78b768f0 to your computer and use it in GitHub Desktop.
PhantomJS script for rendering Cambridge Latin Course online textbooks into a multi-page PDF
This file contains 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 url = 'http://cambridgescp.com/singles/webbook/s47/sdfg47jkl51poa.html'; | |
var page = require('webpage').create(); | |
page.paperSize = { width: '480px', height: '620px', border: '0px' }; | |
page.open(url, function () { | |
page.evaluate(function() { | |
document.getElementById('navigation_instructs').style.display = 'none'; | |
document.body.style.cssText = 'font-family: "Times New Roman" !important'; | |
document.querySelector('#frm').style.position = 'relative'; | |
document.querySelector('#frm').style.left = '0'; | |
var pages = document.querySelectorAll('.pag'); | |
for (var i=0; i<pages.length; i++) { | |
pages[i].style['page-break-before'] = 'always'; | |
pages[i].style.display = 'block !important'; | |
pages[i].style.float = 'none'; | |
pages[i].style.position = 'relative' | |
} | |
}); | |
page.render('output.pdf'); | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment