1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Hack to support automatic printing from pdf javascript.

This commit is contained in:
Brendan Dahl 2013-02-28 15:29:07 -08:00
parent e20a9846ca
commit 5c43565404
4 changed files with 120 additions and 23 deletions

View file

@ -1310,6 +1310,26 @@ var PDFView = {
}
self.pagesRefMap = pagesRefMap;
// Wait to do this here so all the canvases are setup.
if (PDFView.supportsPrinting) {
pdfDocument.getJavaScript().then(function(javaScript) {
if (javaScript.length) {
PDFView.fallback();
}
// Hack to support auto printing.
var regex = /\bprint\s*\(/g;
for (var i = 0, ii = javaScript.length; i < ii; i++) {
var js = javaScript[i];
if (js && regex.test(js)) {
setTimeout(function() {
window.print();
});
return;
}
}
});
}
});
var destinationsPromise = pdfDocument.getDestinations();