|
|
@ -379,6 +379,17 @@ var PDFView = { |
|
|
|
return currentPageNumber; |
|
|
|
return currentPageNumber; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get supportsPrinting() { |
|
|
|
|
|
|
|
var canvas = document.createElement('canvas'); |
|
|
|
|
|
|
|
var value = 'mozPrintCallback' in canvas; |
|
|
|
|
|
|
|
// shadow
|
|
|
|
|
|
|
|
Object.defineProperty(this, 'supportsPrinting', { value: value, |
|
|
|
|
|
|
|
enumerable: true, |
|
|
|
|
|
|
|
configurable: true, |
|
|
|
|
|
|
|
writable: false }); |
|
|
|
|
|
|
|
return value; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
open: function pdfViewOpen(url, scale, password) { |
|
|
|
open: function pdfViewOpen(url, scale, password) { |
|
|
|
var parameters = {password: password}; |
|
|
|
var parameters = {password: password}; |
|
|
|
if (typeof url === 'string') { // URL
|
|
|
|
if (typeof url === 'string') { // URL
|
|
|
@ -1041,6 +1052,26 @@ var PDFView = { |
|
|
|
params[unescape(key)] = unescape(value); |
|
|
|
params[unescape(key)] = unescape(value); |
|
|
|
} |
|
|
|
} |
|
|
|
return params; |
|
|
|
return params; |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
beforePrint: function pdfViewSetupBeforePrint() { |
|
|
|
|
|
|
|
if (!this.supportsPrinting) { |
|
|
|
|
|
|
|
var printMessage = mozL10n.get('printing_not_supported', null, |
|
|
|
|
|
|
|
'Warning: Printing is not fully supported by this browser.'); |
|
|
|
|
|
|
|
this.error(printMessage); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var body = document.querySelector('body'); |
|
|
|
|
|
|
|
body.setAttribute('data-mozPrintCallback', true); |
|
|
|
|
|
|
|
for (var i = 0, ii = this.pages.length; i < ii; ++i) { |
|
|
|
|
|
|
|
this.pages[i].beforePrint(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
afterPrint: function pdfViewSetupAfterPrint() { |
|
|
|
|
|
|
|
var div = document.getElementById('printContainer'); |
|
|
|
|
|
|
|
while (div.hasChildNodes()) |
|
|
|
|
|
|
|
div.removeChild(div.lastChild); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -1360,6 +1391,44 @@ var PageView = function pageView(container, pdfPage, id, scale, |
|
|
|
div.setAttribute('data-loaded', true); |
|
|
|
div.setAttribute('data-loaded', true); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.beforePrint = function pageViewBeforePrint() { |
|
|
|
|
|
|
|
var pdfPage = this.pdfPage; |
|
|
|
|
|
|
|
var viewport = pdfPage.getViewport(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var canvas = this.canvas = document.createElement('canvas'); |
|
|
|
|
|
|
|
canvas.width = viewport.width; |
|
|
|
|
|
|
|
canvas.height = viewport.height; |
|
|
|
|
|
|
|
canvas.style.width = viewport.width + 'pt'; |
|
|
|
|
|
|
|
canvas.style.height = viewport.height + 'pt'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var printContainer = document.getElementById('printContainer'); |
|
|
|
|
|
|
|
printContainer.appendChild(canvas); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
canvas.mozPrintCallback = function(obj) { |
|
|
|
|
|
|
|
var ctx = obj.context; |
|
|
|
|
|
|
|
var renderContext = { |
|
|
|
|
|
|
|
canvasContext: ctx, |
|
|
|
|
|
|
|
viewport: viewport |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pdfPage.render(renderContext).then(function() { |
|
|
|
|
|
|
|
// Tell the printEngine that rendering this canvas/page has finished.
|
|
|
|
|
|
|
|
obj.done(); |
|
|
|
|
|
|
|
self.pdfPage.destroy(); |
|
|
|
|
|
|
|
}, function(error) { |
|
|
|
|
|
|
|
console.error(error); |
|
|
|
|
|
|
|
// Tell the printEngine that rendering this canvas/page has failed.
|
|
|
|
|
|
|
|
// This will make the print proces stop.
|
|
|
|
|
|
|
|
if ('abort' in object) |
|
|
|
|
|
|
|
obj.abort(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
obj.done(); |
|
|
|
|
|
|
|
self.pdfPage.destroy(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.updateStats = function pageViewUpdateStats() { |
|
|
|
this.updateStats = function pageViewUpdateStats() { |
|
|
|
if (PDFJS.pdfBug && Stats.enabled) { |
|
|
|
if (PDFJS.pdfBug && Stats.enabled) { |
|
|
|
var stats = this.stats; |
|
|
|
var stats = this.stats; |
|
|
@ -1706,6 +1775,10 @@ window.addEventListener('load', function webViewerLoad(evt) { |
|
|
|
document.querySelector('#viewSearch').classList.remove('hidden'); |
|
|
|
document.querySelector('#viewSearch').classList.remove('hidden'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!PDFView.supportsPrinting) { |
|
|
|
|
|
|
|
document.getElementById('print').classList.add('hidden'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Listen for warnings to trigger the fallback UI. Errors should be caught
|
|
|
|
// Listen for warnings to trigger the fallback UI. Errors should be caught
|
|
|
|
// and call PDFView.error() so we don't need to listen for those.
|
|
|
|
// and call PDFView.error() so we don't need to listen for those.
|
|
|
|
PDFJS.LogManager.addLogger({ |
|
|
|
PDFJS.LogManager.addLogger({ |
|
|
@ -1960,3 +2033,11 @@ window.addEventListener('keydown', function keydown(evt) { |
|
|
|
evt.preventDefault(); |
|
|
|
evt.preventDefault(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('beforeprint', function beforePrint(evt) { |
|
|
|
|
|
|
|
PDFView.beforePrint(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('afterprint', function afterPrint(evt) { |
|
|
|
|
|
|
|
PDFView.afterPrint(); |
|
|
|
|
|
|
|
}); |
|
|
|