From 92f3592c2c2f6b10bf6a18a0b73d580816b7ed3f Mon Sep 17 00:00:00 2001 From: Philo Mushofi El Haries Date: Thu, 25 Apr 2024 10:13:16 +0700 Subject: [PATCH] handle file can not be opened because of pdf containts password --- .../src/main/java/com/rajat/pdfviewer/PdfRendererView.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pdfViewer/src/main/java/com/rajat/pdfviewer/PdfRendererView.kt b/pdfViewer/src/main/java/com/rajat/pdfviewer/PdfRendererView.kt index 0a06273..5d4948f 100644 --- a/pdfViewer/src/main/java/com/rajat/pdfviewer/PdfRendererView.kt +++ b/pdfViewer/src/main/java/com/rajat/pdfviewer/PdfRendererView.kt @@ -92,8 +92,12 @@ class PdfRendererView @JvmOverloads constructor( statusListener?.onPdfLoadProgress(progress, currentBytes, totalBytes) } override fun onDownloadSuccess(absolutePath: String) { - initWithFile(File(absolutePath)) - statusListener?.onPdfLoadSuccess(absolutePath) + try { + initWithFile(File(absolutePath)) + statusListener?.onPdfLoadSuccess(absolutePath) + } catch (e: Exception) { + statusListener?.onError(e) + } } override fun onError(error: Throwable) { error.printStackTrace()