How does one decrypt a PDF with an owner password, but no user password?

Posted by Tony Meyer on Stack Overflow See other posts from Stack Overflow or by Tony Meyer
Published on 2008-09-08T10:55:13Z Indexed on 2010/04/02 4:03 UTC
Read the original article Hit count: 336

Filed under:
|
|
|
|

Although the PDF specification is available from Adobe, it's not exactly the simplest document to read through. PDF allows documents to be encrypted so that either a user password and/or an owner password is required to do various things with the document (display, print, etc). A common use is to lock a PDF so that end users can read it without entering any password, but a password is required to do anything else.

I'm trying to parse PDFs that are locked in this way (to get the same privileges as you would get opening them in any reader). Using an empty string as the user password doesn't work, but it seems (section 3.5.2 of the spec) that there has to be a user password to create the hash for the admin password.

What I would like is either an explanation of how to do this, or any code that I can read (ideally Python, C, or C++, but anything readable will do) that does this so that I can understand what I'm meant to be doing. Standalone code, rather than reading through (e.g.) the gsview source, would be best.

© Stack Overflow or respective owner

Related posts about c++

Related posts about python