casperjs - Setting paperSize for PDF printing in Casper -


in generating pdfs in phantom, can set paper size this:

page.papersize = {   height: '8.5in',   width: '11in',   orientation: 'landscape',   border: '0.4in' }; 

then page.render(output) function generates pdf properly. in other words, size correct , has many pages of size.

i can't work in casper (and i'm not sure if supported). example, following:

var casper = require('casper').create({     papersize: {       height: '8.5in',       width: '11in',       orientation: 'landscape',       border: '0.4in'     },     loglevel: 'debug',     verbose: true });  ....this.capture('print.pdf'); ... 

creates pdf single, long page. setting viewportsize not fix problem.

is there way access pagesize object within casperjs?

you can access papersize through casper.page.papersize, need set after calling casper.start(), otherwise casper.page equal null.

here's example:

var casper = require("casper").create(); casper.start();  casper.page.papersize = {   width: '11in',   height: '8.5in',   orientation: 'landscape',   border: '0.4in' };  casper.thenopen('http://www.facebook.com/', function() {   this.capture('test.pdf');   this.echo('created pdf.'); });  casper.run(); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -