Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2089,19 +2089,32 @@ var PageView = function pageView(container, pdfPage, id, scale,
this.beforePrint = function pageViewBeforePrint() {
var pdfPage = this.pdfPage;
var viewport = pdfPage.getViewport(1);

// Use the same hack we use for high dpi displays for printing to get better
// output until bug 811002 is fixed in FF.
var PRINT_OUTPUT_SCALE = 2;
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';
canvas.width = Math.floor(viewport.width) * PRINT_OUTPUT_SCALE;
canvas.height = Math.floor(viewport.height) * PRINT_OUTPUT_SCALE;
canvas.style.width = (PRINT_OUTPUT_SCALE * viewport.width) + 'pt';
canvas.style.height = (PRINT_OUTPUT_SCALE * viewport.height) + 'pt';
var cssScale = 'scale(' + (1 / PRINT_OUTPUT_SCALE) + ', ' +
(1 / PRINT_OUTPUT_SCALE) + ')';
CustomStyle.setProp('transform' , canvas, cssScale);
CustomStyle.setProp('transformOrigin' , canvas, '0% 0%');

var printContainer = document.getElementById('printContainer');
printContainer.appendChild(canvas);

var self = this;
canvas.mozPrintCallback = function(obj) {
var ctx = obj.context;

ctx.save();
ctx.fillStyle = 'rgb(255, 255, 255)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.restore();
ctx.scale(PRINT_OUTPUT_SCALE, PRINT_OUTPUT_SCALE);

var renderContext = {
canvasContext: ctx,
viewport: viewport
Expand Down