How do I bypass the owner password?

Requirement is to process a batch of PDFs one at a time and on success encrypt each of them with an user password. However, these PDFs were encrypted previously with randomly generated dynamic owner password (not known to any one) to prevent any edits.

I use iText for encryption as shown below:

byte[] userPass = "user".getBytes();
byte[] ownerPass = "owner".getBytes();
PdfReader reader = new PdfReader("Misc.pdf");
PdfStamper stamper = new PdfStamper(reader,
    new FileOutputStream("Processed_Encrypted.pdf"));
stamper.setEncryption(userPass, ownerPass,
But this code throws an com.itextpdf.text.exceptions.BadPasswordException: PdfReader not opened with owner password

Can some one guide on how to resolve this error / bypass owner password?

Here I would like to make clear that we legally own these PDFs, so no crime / hacking is committed.

Posted on StackOverflow on Apr 11, 2013 by Bond - Java Bond

PdfReader has an undocumented boolean variable named unethicalReading. For obvious reasons, this variable is set to false by default. You could set this variable to true in iText 7 like this:


From now on, PdfReader will ignore the presence of an owner password. It will only throw an exception if a user password is in place. Use this at your own risk.

Click How to read PDFs created with an unknown random owner password? if you want to see how to answer this question in iText 5.