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:
parent
e20a9846ca
commit
5c43565404
4 changed files with 120 additions and 23 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue