diff --git a/lib/core/viewer/components/pdf-viewer.component.ts b/lib/core/viewer/components/pdf-viewer.component.ts index e2746e890c..43c8ec703e 100644 --- a/lib/core/viewer/components/pdf-viewer.component.ts +++ b/lib/core/viewer/components/pdf-viewer.component.ts @@ -33,6 +33,7 @@ import { RenderingQueueServices } from '../services/rendering-queue.services'; import { PdfPasswordDialogComponent } from './pdf-viewer-password-dialog'; import { AppConfigService } from './../../app-config/app-config.service'; import { PDFDocumentProxy, PDFSource } from 'pdfjs-dist'; +import { timer } from 'rxjs'; declare const pdfjsLib: any; declare const pdfjsViewer: any; @@ -236,15 +237,15 @@ export class PdfViewerComponent implements OnChanges, OnDestroy { } if (this.loadingTask) { - try { - this.loadingTask.destroy(); - } catch { - } - - this.loadingTask = null; + timer(700).subscribe(() => this.destroyPdJsWorker()); } } + private destroyPdJsWorker() { + this.loadingTask.destroy(); + this.loadingTask = null; + } + toggleThumbnails() { this.showThumbnails = !this.showThumbnails; }