I have adopted a website and I cannot figure something out. The website uses CasperJS called from the command line, which logs into the site and then generates a PDF from the HTML that is downloaded. I think CasperJS will use PhantomJS for the PDF generation, using capture().
I need to add page numbers and the total pages to the PDF. So Page 1 of 5 for example. But I cannot find any details online how to do this with CasperJS and PhantomJS. Is it possible?
The download process creates the following JS file on the server, which is called below:
var casper = require('casper').create({ verbose: false, logLevel: 'debug', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22', pageSettings: { loadImages: true, loadPlugins: true }, }); var url = '{$siteurl}'; casper.start(url, function() { this.page.paperSize = { width: '11in', height: '8.5in', orientation: 'landscape', border: '0.1in' }; this.fill('form#loginform', { ident: 'username', password: 'password' }, true); }); var url = '{$siteurl}/pdf/{$twigDate}/{$clubId}/{$sessionId}'; casper.then(function() { casper.start(url, function() { this.capture('{$genPdf}'); }); }); casper.run();
Then the above file is called with:
$exe = shell_exec('/usr/bin/casperjs --ignore-ssl-errors=true --ssl-protocol=any ' . INC_ROOT . '/pdf/registers/' . $filename . ' 2>&1');
Thanks
0 comments:
Post a Comment