简体   繁体   中英

Open PDF with headless browser Phantomjs

I have a pdf that is hosted on an s3 server, I would like to open the pdf and take screenshots within phantomjs. Everytime I get a status of fail. I looked around and cannot seem to find an easy solution

var page = require('webpage').create();
var link = 'http://vfs.velma.com/Velma/testcard.pdf'; 
page.open(link, function(status) {
if (status!=='success') {
    console.log(status);
    phantom.exit();
} 
console.log(status);
phantom.exit();
});//ends page open()

I searched the docs but found nothing regarding opening a pdf. My ultimate goal is to screenshot the pdf and injecting an overlay image with jquery. Is this possible using only phantomjs and jquery?

PDF file is not a webpage, so naturally PhantomJS will not render it. However there are projects and services that make possible rendering PDF in a browser, like Mozilla's pdf.js or Google's online PDF viewer .

Since those produce valid HTML, you could work with them in PhantomJS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM