Skip to content

Commit

Permalink
Changes to viewer to support progressive loading
Browse files Browse the repository at this point in the history
  • Loading branch information
mduan committed Mar 29, 2013
1 parent 921f321 commit 4782a3a
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 82 deletions.
1 change: 1 addition & 0 deletions l10n/en-US/viewer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ text_annotation_type=[{{type}} Annotation]
request_password=PDF is protected by a password:

printing_not_supported=Warning: Printing is not fully supported by this browser.
printing_not_ready=Warning: The PDF is not fully loaded for printing.
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.
19 changes: 15 additions & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,19 @@ var Util = PDFJS.Util = (function UtilClosure() {
})();

var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
function PageViewport(viewBox, scale, rotate, offsetX, offsetY) {
function PageViewport(viewBox, scale, rotation, offsetX, offsetY) {
this.viewBox = viewBox;
this.scale = scale;
this.rotation = rotation;
this.offsetX = offsetX;
this.offsetY = offsetY;

// creating transform to convert pdf coordinate system to the normal
// canvas like coordinates taking in account scale and rotation
var centerX = (viewBox[2] + viewBox[0]) / 2;
var centerY = (viewBox[3] + viewBox[1]) / 2;
var rotateA, rotateB, rotateC, rotateD;
switch (rotate % 360) {
switch (rotation % 360) {
case -180:
case 180:
rotateA = -1; rotateB = 0; rotateC = 0; rotateD = 1;
Expand Down Expand Up @@ -412,13 +418,18 @@ var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
];

this.offsetX = offsetX;
this.offsetY = offsetY;
this.width = width;
this.height = height;
this.fontScale = scale;
}
PageViewport.prototype = {
clone: function PageViewPort_clone(args) {
args = args || {};
var scale = 'scale' in args ? args.scale : this.scale;
var rotation = 'rotation' in args ? args.rotation : this.rotation;
return new PageViewport(this.viewBox.slice(), scale, rotation,
this.offsetX, this.offsetY);
},
convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
return Util.applyTransform([x, y], this.transform);
},
Expand Down
Loading

0 comments on commit 4782a3a

Please sign in to comment.