|
|
@ -734,7 +734,22 @@ var Util = PDFJS.Util = (function UtilClosure() { |
|
|
|
return Util; |
|
|
|
return Util; |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* PDF page viewport created based on scale, rotation and offset. |
|
|
|
|
|
|
|
* @class |
|
|
|
|
|
|
|
* @alias PDFJS.PageViewport |
|
|
|
|
|
|
|
*/ |
|
|
|
var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() { |
|
|
|
var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @constructor |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
* @param viewBox {Array} xMin, yMin, xMax and yMax coordinates. |
|
|
|
|
|
|
|
* @param scale {number} scale of the viewport. |
|
|
|
|
|
|
|
* @param rotation {number} rotations of the viewport in degrees. |
|
|
|
|
|
|
|
* @param offsetX {number} offset X |
|
|
|
|
|
|
|
* @param offsetY {number} offset Y |
|
|
|
|
|
|
|
* @param dontFlip {boolean} if true, axis Y will not be flipped. |
|
|
|
|
|
|
|
*/ |
|
|
|
function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) { |
|
|
|
function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) { |
|
|
|
this.viewBox = viewBox; |
|
|
|
this.viewBox = viewBox; |
|
|
|
this.scale = scale; |
|
|
|
this.scale = scale; |
|
|
@ -798,7 +813,14 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() { |
|
|
|
this.height = height; |
|
|
|
this.height = height; |
|
|
|
this.fontScale = scale; |
|
|
|
this.fontScale = scale; |
|
|
|
} |
|
|
|
} |
|
|
|
PageViewport.prototype = { |
|
|
|
PageViewport.prototype = /** @lends PDFJS.PageViewport.prototype */ { |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Clones viewport with additional properties. |
|
|
|
|
|
|
|
* @param args {Object} (optional) If specified, may contain the 'scale' or |
|
|
|
|
|
|
|
* 'rotation' properties to override the corresponding properties in |
|
|
|
|
|
|
|
* the cloned viewport. |
|
|
|
|
|
|
|
* @returns {PDFJS.PageViewport} Cloned viewport. |
|
|
|
|
|
|
|
*/ |
|
|
|
clone: function PageViewPort_clone(args) { |
|
|
|
clone: function PageViewPort_clone(args) { |
|
|
|
args = args || {}; |
|
|
|
args = args || {}; |
|
|
|
var scale = 'scale' in args ? args.scale : this.scale; |
|
|
|
var scale = 'scale' in args ? args.scale : this.scale; |
|
|
@ -806,15 +828,41 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() { |
|
|
|
return new PageViewport(this.viewBox.slice(), scale, rotation, |
|
|
|
return new PageViewport(this.viewBox.slice(), scale, rotation, |
|
|
|
this.offsetX, this.offsetY, args.dontFlip); |
|
|
|
this.offsetX, this.offsetY, args.dontFlip); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Converts PDF point to the viewport coordinates. For examples, useful for |
|
|
|
|
|
|
|
* converting PDF location into canvas pixel coordinates. |
|
|
|
|
|
|
|
* @param x {number} X coordinate. |
|
|
|
|
|
|
|
* @param y {number} Y coordinate. |
|
|
|
|
|
|
|
* @returns {Object} Object that contains 'x' and 'y' properties of the |
|
|
|
|
|
|
|
* point in the viewport coordinate space. |
|
|
|
|
|
|
|
* @see {@link convertToPdfPoint} |
|
|
|
|
|
|
|
* @see {@link convertToViewportRectangle} |
|
|
|
|
|
|
|
*/ |
|
|
|
convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) { |
|
|
|
convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) { |
|
|
|
return Util.applyTransform([x, y], this.transform); |
|
|
|
return Util.applyTransform([x, y], this.transform); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Converts PDF rectangle to the viewport coordinates. |
|
|
|
|
|
|
|
* @param rect {Array} xMin, yMin, xMax and yMax coordinates. |
|
|
|
|
|
|
|
* @returns {Array} Contains corresponding coordinates of the rectangle |
|
|
|
|
|
|
|
* in the viewport coordinate space. |
|
|
|
|
|
|
|
* @see {@link convertToViewportPoint} |
|
|
|
|
|
|
|
*/ |
|
|
|
convertToViewportRectangle: |
|
|
|
convertToViewportRectangle: |
|
|
|
function PageViewport_convertToViewportRectangle(rect) { |
|
|
|
function PageViewport_convertToViewportRectangle(rect) { |
|
|
|
var tl = Util.applyTransform([rect[0], rect[1]], this.transform); |
|
|
|
var tl = Util.applyTransform([rect[0], rect[1]], this.transform); |
|
|
|
var br = Util.applyTransform([rect[2], rect[3]], this.transform); |
|
|
|
var br = Util.applyTransform([rect[2], rect[3]], this.transform); |
|
|
|
return [tl[0], tl[1], br[0], br[1]]; |
|
|
|
return [tl[0], tl[1], br[0], br[1]]; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Converts viewport coordinates to the PDF location. For examples, useful |
|
|
|
|
|
|
|
* for converting canvas pixel location into PDF one. |
|
|
|
|
|
|
|
* @param x {number} X coordinate. |
|
|
|
|
|
|
|
* @param y {number} Y coordinate. |
|
|
|
|
|
|
|
* @returns {Object} Object that contains 'x' and 'y' properties of the |
|
|
|
|
|
|
|
* point in the PDF coordinate space. |
|
|
|
|
|
|
|
* @see {@link convertToViewportPoint} |
|
|
|
|
|
|
|
*/ |
|
|
|
convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) { |
|
|
|
convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) { |
|
|
|
return Util.applyInverseTransform([x, y], this.transform); |
|
|
|
return Util.applyInverseTransform([x, y], this.transform); |
|
|
|
} |
|
|
|
} |
|
|
@ -944,6 +992,8 @@ function isPDFFunction(v) { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Creates a promise capability object. |
|
|
|
* Creates a promise capability object. |
|
|
|
|
|
|
|
* @alias PDFJS.createPromiseCapability |
|
|
|
|
|
|
|
* |
|
|
|
* @return {PromiseCapability} A capability object contains: |
|
|
|
* @return {PromiseCapability} A capability object contains: |
|
|
|
* - a Promise, resolve and reject methods. |
|
|
|
* - a Promise, resolve and reject methods. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|