Permalink
Browse files

Removes mozPrintCallback polyfill, converts canvas to PNG.

  • Loading branch information...
yurydelendik committed Oct 8, 2016
1 parent 24a7a58 commit c09f634bb6c713f6dc36628145788c88e60448e0
@@ -244,13 +244,13 @@ function createWebBundle(defines) {
amdName = 'pdfjs-dist/web/viewer';
outputName = 'viewer.js';
template = 'web/viewer.js';
files = ['app.js', 'firefox_print_service.js'];
files = ['app.js'];
if (defines.FIREFOX || defines.MOZCENTRAL) {
files.push('firefoxcom.js');
files.push('firefoxcom.js', 'firefox_print_service.js');
} else if (defines.CHROME) {
files.push('chromecom.js', 'mozPrintCallback_polyfill.js');
files.push('chromecom.js', 'pdf_print_service.js');
} else if (defines.GENERIC) {
files.push('mozPrintCallback_polyfill.js');
files.push('pdf_print_service.js');
}
}

@@ -1100,6 +1100,13 @@ var PDFViewerApplication = {
},

beforePrint: function pdfViewSetupBeforePrint() {
if (this.printService) {
// There is no way to suppress beforePrint/afterPrint events,
// but PDFPrintService may generate double events -- this will ignore
// the second event that will be coming from native window.print().
return;
}

if (!this.supportsPrinting) {
var printMessage = mozL10n.get('printing_not_supported', null,
'Warning: Printing is not fully supported by this browser.');
@@ -85,7 +85,6 @@
this.pdfDocument = pdfDocument;
this.pagesOverview = pagesOverview;
this.printContainer = printContainer;
this.pageStyleSheet = null;
}

FirefoxPrintService.prototype = {
@@ -95,45 +94,13 @@
var body = document.querySelector('body');
body.setAttribute('data-pdfjsprinting', true);

var hasEqualPageSizes = this.pagesOverview.every(function (size) {
return size.width === this.pagesOverview[0].width &&
size.height === this.pagesOverview[0].height;
}, this);
if (!hasEqualPageSizes) {
console.warn('Not all pages have the same size. The printed ' +
'result may be incorrect!');
}

// Insert a @page + size rule to make sure that the page size is correctly
// set. Note that we assume that all pages have the same size, because
// variable-size pages are not supported yet (e.g. in Chrome & Firefox).
// TODO(robwu): Use named pages when size calculation bugs get resolved
// (e.g. https://crbug.com/355116) AND when support for named pages is
// added (http://www.w3.org/TR/css3-page/#using-named-pages).
// In browsers where @page + size is not supported (such as Firefox,
// https://bugzil.la/851441), the next stylesheet will be ignored and the
// user has to select the correct paper size in the UI if wanted.
this.pageStyleSheet = document.createElement('style');
var pageSize = this.pagesOverview[0];
this.pageStyleSheet.textContent =
// "size:<width> <height>" is what we need. But also add "A4" because
// Firefox incorrectly reports support for the other value.
'@supports ((size:A4) and (size:1pt 1pt)) {' +
'@page { size: ' + pageSize.width + 'pt ' + pageSize.height + 'pt;}' +
'}';
body.appendChild(this.pageStyleSheet);

for (var i = 0, ii = this.pagesOverview.length; i < ii; ++i) {
composePage(pdfDocument, i + 1, this.pagesOverview[i], printContainer);
}
},

destroy: function () {
this.printContainer.textContent = '';
if (this.pageStyleSheet && this.pageStyleSheet.parentNode) {
this.pageStyleSheet.parentNode.removeChild(this.pageStyleSheet);
this.pageStyleSheet = null;
}
}
};

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit c09f634

Please sign in to comment.