Open pdf by link and make capture

142 Views Asked by At

I using casperjs, so some example:

casper.start('http://lacoa.org/pdf/emergencysurvivalguide-lowres.pdf', function() {
    this.wait(1000, function() {
        casper.capture(filepath);
    });
});

I understand that it is a file, not a page, but can I open a file in the browser and make capture? Thanks.

1

There are 1 best solutions below

0
Rippo On

You are looking for casper.download

var pdfUri = 'http://lacoa.org/pdf/emergencysurvivalguide-lowres.pdf';

var casper = require('casper').create();
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');

casper.start('http://lacoa.org', function () {
    this.echo('Downloading ' + pdfUri);
    this.download(pdfUri, 'download.pdf');
});

casper.run(function () {
    this.echo('Done.').exit();
});

This takes a few moments to download