Search code examples
androidpdfpassword-protectionmupdf

How to read password protected/ remove password from pdf in android?


I am using MuPDF Library to read a PDF inside application. For a normal pdf, It is working fine for me. But for a password protected pdf, I couldn't open my pdf. How to make it possible? Anyone can help me? I used sample code:

private MuPDFCore openFile(String path) {
        int lastSlashPos = path.lastIndexOf('/');
        mFilePath = lastSlashPos == -1 ? path : path.substring(lastSlashPos + 1);
        try {
            core = new MuPDFCore(mContext, path);
        } catch (Exception e) {
            Log.e(tag, "Error: "+e.getMessage());
            return null;
        }
        return core;
    }

Solution

  • Look at requestPassword (and the calls to it) in MuPDFActivity.java in the mupdf Android example code.