mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge branch 'master' of git://github.com/mozilla/pdf.js.git into textlayout-ui
Conflicts: src/canvas.js
This commit is contained in:
commit
edb0ae4eb8
10 changed files with 97 additions and 44 deletions
|
@ -255,6 +255,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
}
|
||||
// Scale so that canvas units are the same as PDF user space units
|
||||
this.ctx.scale(cw / mediaBox.width, ch / mediaBox.height);
|
||||
// Move the media left-top corner to the (0,0) canvas position
|
||||
this.ctx.translate(-mediaBox.x, -mediaBox.y);
|
||||
|
||||
if (this.textLayer)
|
||||
this.textLayer.beginLayout();
|
||||
|
@ -341,6 +343,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
setDash: function canvasGraphicsSetDash(dashArray, dashPhase) {
|
||||
this.ctx.mozDash = dashArray;
|
||||
this.ctx.mozDashOffset = dashPhase;
|
||||
this.ctx.webkitLineDash = dashArray;
|
||||
this.ctx.webkitLineDashOffset = dashPhase;
|
||||
},
|
||||
setRenderingIntent: function canvasGraphicsSetRenderingIntent(intent) {
|
||||
TODO('set rendering intent: ' + intent);
|
||||
|
|
44
src/core.js
44
src/core.js
|
@ -70,8 +70,7 @@ var Page = (function PageClosure() {
|
|||
this.xref = xref;
|
||||
this.ref = ref;
|
||||
|
||||
this.ctx = null;
|
||||
this.callback = null;
|
||||
this.displayReadyPromise = null;
|
||||
}
|
||||
|
||||
Page.prototype = {
|
||||
|
@ -110,9 +109,11 @@ var Page = (function PageClosure() {
|
|||
width: this.width,
|
||||
height: this.height
|
||||
};
|
||||
var mediaBox = this.mediaBox;
|
||||
var offsetX = mediaBox[0], offsetY = mediaBox[1];
|
||||
if (isArray(obj) && obj.length == 4) {
|
||||
var tl = this.rotatePoint(obj[0], obj[1]);
|
||||
var br = this.rotatePoint(obj[2], obj[3]);
|
||||
var tl = this.rotatePoint(obj[0] - offsetX, obj[1] - offsetY);
|
||||
var br = this.rotatePoint(obj[2] - offsetX, obj[3] - offsetY);
|
||||
view.x = Math.min(tl.x, br.x);
|
||||
view.y = Math.min(tl.y, br.y);
|
||||
view.width = Math.abs(tl.x - br.x);
|
||||
|
@ -165,20 +166,12 @@ var Page = (function PageClosure() {
|
|||
IRQueue, fonts) {
|
||||
var self = this;
|
||||
this.IRQueue = IRQueue;
|
||||
var gfx = new CanvasGraphics(this.ctx, this.objs, this.textLayer);
|
||||
|
||||
var displayContinuation = function pageDisplayContinuation() {
|
||||
// Always defer call to display() to work around bug in
|
||||
// Firefox error reporting from XHR callbacks.
|
||||
setTimeout(function pageSetTimeout() {
|
||||
try {
|
||||
self.display(gfx, self.callback);
|
||||
} catch (e) {
|
||||
if (self.callback)
|
||||
self.callback(e);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
self.displayReadyPromise.resolve();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -395,12 +388,27 @@ var Page = (function PageClosure() {
|
|||
return items;
|
||||
},
|
||||
startRendering: function pageStartRendering(ctx, callback, textLayer) {
|
||||
this.ctx = ctx;
|
||||
this.callback = callback;
|
||||
this.textLayer = textLayer;
|
||||
|
||||
this.startRenderingTime = Date.now();
|
||||
this.pdf.startRendering(this);
|
||||
|
||||
// If there is no displayReadyPromise yet, then the IRQueue was never
|
||||
// requested before. Make the request and create the promise.
|
||||
if (!this.displayReadyPromise) {
|
||||
this.pdf.startRendering(this);
|
||||
this.displayReadyPromise = new Promise();
|
||||
}
|
||||
|
||||
// Once the IRQueue and fonts are loaded, perform the actual rendering.
|
||||
this.displayReadyPromise.then(function pageDisplayReadyPromise() {
|
||||
var gfx = new CanvasGraphics(ctx, this.objs, textLayer);
|
||||
try {
|
||||
this.display(gfx, callback);
|
||||
} catch (e) {
|
||||
if (self.callback)
|
||||
self.callback(e);
|
||||
else
|
||||
throw e;
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2092,7 +2092,7 @@ var Font = (function FontClosure() {
|
|||
window.btoa(data) + ');');
|
||||
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}';
|
||||
|
||||
document.documentElement.firstChild.appendChild(
|
||||
document.documentElement.getElementsByTagName('head')[0].appendChild(
|
||||
document.createElement('style'));
|
||||
|
||||
var styleSheet = document.styleSheets[document.styleSheets.length - 1];
|
||||
|
|
|
@ -270,7 +270,6 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
|
||||
constructStiched: function pdfFunctionConstructStiched(fn, dict, xref) {
|
||||
var domain = dict.get('Domain');
|
||||
var range = dict.get('Range');
|
||||
|
||||
if (!domain)
|
||||
error('No domain');
|
||||
|
@ -279,13 +278,13 @@ var PDFFunction = (function PDFFunctionClosure() {
|
|||
if (inputSize != 1)
|
||||
error('Bad domain for stiched function');
|
||||
|
||||
var fnRefs = dict.get('Functions');
|
||||
var fnRefs = xref.fetchIfRef(dict.get('Functions'));
|
||||
var fns = [];
|
||||
for (var i = 0, ii = fnRefs.length; i < ii; ++i)
|
||||
fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
|
||||
|
||||
var bounds = dict.get('Bounds');
|
||||
var encode = dict.get('Encode');
|
||||
var bounds = xref.fetchIfRef(dict.get('Bounds'));
|
||||
var encode = xref.fetchIfRef(dict.get('Encode'));
|
||||
|
||||
return [CONSTRUCT_STICHED, domain, bounds, encode, fns];
|
||||
},
|
||||
|
|
|
@ -284,7 +284,7 @@ var Promise = (function PromiseClosure() {
|
|||
}
|
||||
|
||||
this.isResolved = true;
|
||||
this.data = data;
|
||||
this.data = data || null;
|
||||
var callbacks = this.callbacks;
|
||||
|
||||
for (var i = 0, ii = callbacks.length; i < ii; i++) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue