|
|
|
@ -1072,6 +1072,21 @@ var PDFView = {
@@ -1072,6 +1072,21 @@ var PDFView = {
|
|
|
|
|
//#endif
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns scale factor for the canvas. It makes sense for the HiDPI displays. |
|
|
|
|
* @return {Object} The object with horizontal (sx) and vertical (sy) |
|
|
|
|
scales. The scaled property is set to false if scaling is |
|
|
|
|
not required, true otherwise. |
|
|
|
|
*/ |
|
|
|
|
getOutputScale: function pdfViewGetOutputDPI() { |
|
|
|
|
var pixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1; |
|
|
|
|
return { |
|
|
|
|
sx: pixelRatio, |
|
|
|
|
sy: pixelRatio, |
|
|
|
|
scaled: pixelRatio != 1 |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Show the error box. |
|
|
|
|
* @param {String} message A message that is human readable. |
|
|
|
@ -1957,14 +1972,29 @@ var PageView = function pageView(container, pdfPage, id, scale,
@@ -1957,14 +1972,29 @@ var PageView = function pageView(container, pdfPage, id, scale,
|
|
|
|
|
textLayerDiv ? new TextLayerBuilder(textLayerDiv, this.id - 1) : null; |
|
|
|
|
|
|
|
|
|
var scale = this.scale, viewport = this.viewport; |
|
|
|
|
canvas.width = Math.floor(viewport.width); |
|
|
|
|
canvas.height = Math.floor(viewport.height); |
|
|
|
|
var outputScale = PDFView.getOutputScale(); |
|
|
|
|
canvas.width = Math.floor(viewport.width) * outputScale.sx; |
|
|
|
|
canvas.height = Math.floor(viewport.height) * outputScale.sy; |
|
|
|
|
|
|
|
|
|
if (outputScale.scaled) { |
|
|
|
|
var cssScale = 'scale(' + (1 / outputScale.sx) + ', ' + |
|
|
|
|
(1 / outputScale.sy) + ')'; |
|
|
|
|
CustomStyle.setProp('transform' , canvas, cssScale); |
|
|
|
|
CustomStyle.setProp('transformOrigin' , canvas, '0% 0%'); |
|
|
|
|
if (textLayerDiv) { |
|
|
|
|
CustomStyle.setProp('transform' , textLayerDiv, cssScale); |
|
|
|
|
CustomStyle.setProp('transformOrigin' , textLayerDiv, '0% 0%'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var ctx = canvas.getContext('2d'); |
|
|
|
|
ctx.save(); |
|
|
|
|
ctx.fillStyle = 'rgb(255, 255, 255)'; |
|
|
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height); |
|
|
|
|
ctx.restore(); |
|
|
|
|
if (outputScale.scaled) { |
|
|
|
|
ctx.scale(outputScale.sx, outputScale.sy); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Rendering area
|
|
|
|
|
|
|
|
|
|