Skip to content

Open a Local PDF File with ComPDFKit on Android

Youna edited this page Mar 7, 2023 · 2 revisions

CPDFDocument document = new CPDFDocument(context); // Open document CPDFDocument.PDFDocumentError error = document.open(pdfUri); if (error == CPDFDocument.PDFDocumentError.PDFDocumentErrorPassword) { // The document is encrypted and requires a password to open. error = document.open(pdfUri, "password"); } if (error == CPDFDocument.PDFDocumentError.PDFDocumentErrorSuccess) { // The document is opened successfully and data can be parsed and manipulated. } else { //The PDF file is failed to open. You can refer to the API file for specific error messages. } //Check if the document has been repaired during the opening process. if (document.hasRepaired()) { //The repaired document needs to be saved first and then opened, otherwise any edits or modifications made to the repaired document cannot be saved. //Perform a save operation ... }

Clone this wiki locally