From 948f17cd11cff05b7978f54529bcbf196e971105 Mon Sep 17 00:00:00 2001 From: Vadym Yatsyuk Date: Mon, 21 Oct 2019 22:45:25 +0200 Subject: [PATCH] add clear method --- src/app/pdf-viewer/pdf-viewer.component.ts | 27 ++++++++++++++++------ 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/app/pdf-viewer/pdf-viewer.component.ts b/src/app/pdf-viewer/pdf-viewer.component.ts index 62e41c000..93a8d9cc4 100644 --- a/src/app/pdf-viewer/pdf-viewer.component.ts +++ b/src/app/pdf-viewer/pdf-viewer.component.ts @@ -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; @@ -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());