diff --git a/src/api.js b/src/api.js index 7d65f96b4..2ab23bdde 100644 --- a/src/api.js +++ b/src/api.js @@ -234,7 +234,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() { * { * canvasContext(required): A 2D context of a DOM Canvas object., * textLayer(optional): An object that has beginLayout, endLayout, and - * appendText functions. + * appendText functions., + * continueCallback(optional): A function that will be called each time + * the rendering is paused. To continue + * rendering call the function that is the + * first argument to the callback. * }. * @return {Promise} A promise that is resolved when the page finishes * rendering. @@ -270,6 +274,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { else promise.resolve(); }; + var continueCallback = params.continueCallback; // Once the operatorList and fonts are loaded, do the actual rendering. this.displayReadyPromise.then( @@ -282,7 +287,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { var gfx = new CanvasGraphics(params.canvasContext, this.objs, params.textLayer); try { - this.display(gfx, params.viewport, complete); + this.display(gfx, params.viewport, complete, continueCallback); } catch (e) { complete(e); } @@ -340,7 +345,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { /** * For internal use only. */ - display: function PDFPageProxy_display(gfx, viewport, callback) { + display: function PDFPageProxy_display(gfx, viewport, callback, + continueCallback) { var stats = this.stats; stats.time('Rendering'); @@ -356,10 +362,16 @@ var PDFPageProxy = (function PDFPageProxyClosure() { stepper.nextBreakPoint = stepper.getNextBreakPoint(); } + var continueWrapper; + if (continueCallback) + continueWrapper = function() { continueCallback(next); } + else + continueWrapper = next; + var self = this; function next() { - startIdx = - gfx.executeOperatorList(operatorList, startIdx, next, stepper); + startIdx = gfx.executeOperatorList(operatorList, startIdx, + continueWrapper, stepper); if (startIdx == length) { gfx.endDrawing(); stats.timeEnd('Rendering'); @@ -367,7 +379,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { if (callback) callback(); } } - next(); + continueWrapper(); }, /** * @return {Promise} That is resolved with the a {string} that is the text diff --git a/src/fonts.js b/src/fonts.js index f74ad4439..e340ab3d9 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -532,7 +532,7 @@ var FontLoader = { // XXX we should have a time-out here too, and maybe fire // pdfjsFontLoadFailed? - var src = '
'; + var src = ''; src += '