@@ -234,7 +234,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
234
234
* {
235
235
* canvasContext(required): A 2D context of a DOM Canvas object.,
236
236
* textLayer(optional): An object that has beginLayout, endLayout, and
237
- * appendText functions.
237
+ * appendText functions.,
238
+ * continueCallback(optional): A function that will be called each time
239
+ * the rendering is paused. To continue
240
+ * rendering call the function that is the
241
+ * first argument to the callback.
238
242
* }.
239
243
* @return {Promise} A promise that is resolved when the page finishes
240
244
* rendering.
@@ -270,6 +274,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
270
274
else
271
275
promise .resolve ();
272
276
};
277
+ var continueCallback = params .continueCallback ;
273
278
274
279
// Once the operatorList and fonts are loaded, do the actual rendering.
275
280
this .displayReadyPromise .then (
@@ -282,7 +287,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
282
287
var gfx = new CanvasGraphics (params .canvasContext ,
283
288
this .objs , params .textLayer );
284
289
try {
285
- this .display (gfx , params .viewport , complete );
290
+ this .display (gfx , params .viewport , complete , continueCallback );
286
291
} catch (e ) {
287
292
complete (e );
288
293
}
@@ -340,7 +345,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
340
345
/**
341
346
* For internal use only.
342
347
*/
343
- display : function PDFPageProxy_display (gfx , viewport , callback ) {
348
+ display : function PDFPageProxy_display (gfx , viewport , callback ,
349
+ continueCallback ) {
344
350
var stats = this .stats ;
345
351
stats .time ('Rendering' );
346
352
@@ -356,18 +362,24 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
356
362
stepper .nextBreakPoint = stepper .getNextBreakPoint ();
357
363
}
358
364
365
+ var continueWrapper ;
366
+ if (continueCallback )
367
+ continueWrapper = function () { continueCallback (next ); }
368
+ else
369
+ continueWrapper = next ;
370
+
359
371
var self = this ;
360
372
function next () {
361
- startIdx =
362
- gfx . executeOperatorList ( operatorList , startIdx , next , stepper );
373
+ startIdx = gfx . executeOperatorList ( operatorList , startIdx ,
374
+ continueWrapper , stepper );
363
375
if (startIdx == length ) {
364
376
gfx .endDrawing ();
365
377
stats .timeEnd ('Rendering' );
366
378
stats .timeEnd ('Overall' );
367
379
if (callback ) callback ();
368
380
}
369
381
}
370
- next ();
382
+ continueWrapper ();
371
383
},
372
384
/**
373
385
* @return {Promise} That is resolved with the a {string} that is the text
0 commit comments