问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/37082485/open-pdf-with-headless-browser-phantomjs