Why do I need the PDF password to open the PDF file

Many people have PDF files which are password protected but for which they no longer have the password, often for perfectly innocent reasons. So they are ask, can JPedal just ignore the password and display the file.

The answer is no because the password is not stored in the PDF just to check against, but it is woven into the entire fabric of the PDF file by PDF security.

A PDF file consists of lots of PDF objects, which contain all the PDF data. You can learn more about this in Daniel’s excellent set of articles on Making your own PDF.

When the PDF is encrypted, the contents of each object is altered using a numeric key. If you open it, the data is garbage. The process needs to be reversed using the complimentary key. And this key is calculated using  a formula which includes the password. It also includes the PDF object number, so each object has its own unique key.

So you need the PDF password to unscramble the data in every object in a PDF file. Otherwise the data is effectively ‘corrupted’ and unusable.

This post is part of our “Understanding the PDF File Format” series. In each article, we discuss a PDF feature, bug, gotcha or tip. If you wish to learn more about PDF, we have 13 years worth of PDF knowledge and tips, so click here to visit our series index!

Related Posts:

The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.
Markee174

About Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>