0

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.

Toxa
  • 63
  • 1
  • 7
  • 1
    Possible duplicate of [Open PDF with headless browser Phantomjs](https://stackoverflow.com/questions/37082485/open-pdf-with-headless-browser-phantomjs) – Vaviloff Aug 01 '17 at 13:53

1 Answers1

0

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

Rippo
  • 22,117
  • 14
  • 78
  • 117