Handle pdf errors when changing docs

This commit is contained in:
shamoon 2024-01-12 22:23:35 -08:00
parent 3dc5213527
commit 2a36c82762

View File

@ -465,8 +465,14 @@ export class PdfViewerComponent
this.clear() this.clear()
if (this.pdfViewer) {
this.pdfViewer._resetView()
this.pdfViewer = null
}
this.setupViewer() this.setupViewer()
try {
this.loadingTask = PDFJS.getDocument(this.getDocumentParams()) this.loadingTask = PDFJS.getDocument(this.getDocumentParams())
this.loadingTask!.onProgress = (progressData: PDFProgressData) => { this.loadingTask!.onProgress = (progressData: PDFProgressData) => {
@ -492,6 +498,9 @@ export class PdfViewerComponent
this.onError.emit(error) this.onError.emit(error)
}, },
}) })
} catch (e) {
this.onError.emit(e)
}
} }
private update() { private update() {