Skip to content

Commit

Permalink
Merge pull request #526 from VadimDez/feature/clear
Browse files Browse the repository at this point in the history
Cancel downloading/rendering, clear rendered pdf
  • Loading branch information
VadimDez authored Oct 21, 2019
2 parents 0062aea + 948f17c commit 2d67cdf
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/app/pdf-viewer/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,25 @@ export class PdfViewerComponent
});
}

public clear() {
if (this.loadingTask && !this.loadingTask.destroyed) {
this.loadingTask.destroy();
}

if (this._pdf) {
this._pdf.destroy();
this._pdf = null;
this.pdfMultiPageViewer.setDocument(null);
this.pdfSinglePageViewer.setDocument(null);

this.pdfMultiPageLinkService.setDocument(null, null);
this.pdfSinglePageLinkService.setDocument(null, null);

this.pdfMultiPageFindController.setDocument(null);
this.pdfSinglePageFindController.setDocument(null);
}
}

private setupMultiPageViewer() {
(PDFJS as any).disableTextLayer = !this._renderText;

Expand Down Expand Up @@ -510,13 +529,7 @@ export class PdfViewerComponent
return;
}

if (this.loadingTask && !this.loadingTask.destroyed) {
this.loadingTask.destroy();
}

if (this._pdf) {
this._pdf.destroy();
}
this.clear();

this.loadingTask = (PDFJS as any).getDocument(this.getDocumentParams());

Expand Down

0 comments on commit 2d67cdf

Please sign in to comment.