Skip to content
Advertisement

How to check if a PDF is Password Protected or not

I am trying to use iText’s PdfReader to check if a given PDF file is password protected or not, but am getting this exception:

Exception in thread “Main Thread” java.lang.NoClassDefFoundError:org/bouncycastle/asn1/ASN1OctetString

But when testing the same code against a non-password protected file it runs fine. Here is the complete code:

JavaScript

Advertisement

Answer

Use Apache PDFBox – Java PDF Library from here:
Sample Code:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement