Browse Source

Fixes content stream reset; terminating rendering when destroyed

Yury Delendik 13 years ago
parent
commit
b6edbb38c1
  1. 9
      src/api.js
  2. 7
      src/core.js

9
src/api.js

@ -233,6 +233,11 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
// Once the operatorList and fonts are loaded, do the actual rendering. // Once the operatorList and fonts are loaded, do the actual rendering.
this.displayReadyPromise.then( this.displayReadyPromise.then(
function pageDisplayReadyPromise() { function pageDisplayReadyPromise() {
if (self.destroyed) {
complete();
return;
}
var gfx = new CanvasGraphics(params.canvasContext, var gfx = new CanvasGraphics(params.canvasContext,
this.objs, params.textLayer); this.objs, params.textLayer);
try { try {
@ -351,8 +356,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.destroyed = true; this.destroyed = true;
if (!this.renderInProgress) { if (!this.renderInProgress) {
delete self.operatorList; delete this.operatorList;
delete self.displayReadyPromise; delete this.displayReadyPromise;
} }
} }
}; };

7
src/core.js

@ -137,10 +137,13 @@ var Page = (function PageClosure() {
var resources = this.resources; var resources = this.resources;
if (isArray(content)) { if (isArray(content)) {
// fetching items // fetching items
var streams = [];
var i, n = content.length; var i, n = content.length;
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
content[i] = xref.fetchIfRef(content[i]); streams.push(xref.fetchIfRef(content[i]));
content = new StreamsSequenceStream(content); content = new StreamsSequenceStream(streams);
} else if (isStream(content)) {
content.reset();
} else if (!content) { } else if (!content) {
// replacing non-existent page content with empty one // replacing non-existent page content with empty one
content = new Stream(new Uint8Array(0)); content = new Stream(new Uint8Array(0));

Loading…
Cancel
Save