Just need to specify paperSize .
Similar to this with the "phantom" module : "0.5.1"
function(next) { phantom.create(function(doc) { next(null, doc); }, "phantomjs", Math.floor(Math.random()*(65535-49152+1)+49152)); }, function(ph, next) { ph.createPage(function(doc) { next(null, doc); }); }, function(page, next) { page.set('paperSize', {format: 'A4', orientation: 'portrait'}); page.set('zoomFactor', 1); }
Then just use page-break-before: always; in your HTML content every time you want to open a new page.
PS: In this example, I am using async.waterfall
PPS: Math.random on the port number is used to avoid module failure if simultaneous phantom binary calls are called. It works well - if someone wants to post something better, even if a little off topic, feel free to do it
source share