yob / pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.
MIT License
1.81k stars 271 forks source link

Some encrypted files don't open #39

Closed janxious closed 12 years ago

janxious commented 12 years ago

I am generating this PDF via PrinceXML(http://princexml.com): http://dl.dropbox.com/u/599002/DocRaptor/test.pdf

It has no user or owner password set. It is encrypted, however. Based on a brief readthrough of the PDF spec, the trailer seemed correct. It opens without password prompting in Preview and Skim.

The exception trace is:

PDF::Reader::EncryptedPDFError: Invalid password ()
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader/standard_security_handler.rb:182:in `build_standard_key'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader/standard_security_handler.rb:66:in `initialize'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader/object_hash.rb:275:in `new'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader/object_hash.rb:275:in `build_security_handler'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader/object_hash.rb:48:in `initialize'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader.rb:116:in `new'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader.rb:116:in `initialize'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader.rb:159:in `new'
    vendor/bundle/ruby/1.8/gems/pdf-reader-1.0.0.rc1/lib/pdf/reader.rb:159:in `open'

Thoughts?

yob commented 12 years ago

@3jb can you shed any light on this issue?

3jb commented 12 years ago

I fixed this in the latest commit to my tree 0d1b03cb8. I'm not sure how to create a pull request as it seems to want you to pull an entire set of spurious commits ( 7 - including the original decrypt commits and a set of upstream pulls). How do you deal with that?

yob commented 12 years ago

Thanks!

To create a clean pull request with just that commit you would have to create a new branch from my master and cherry-pick the single commit, then create the pull request from that branch.

In this case I'll just cherry-pick the commit directly.

janxious commented 12 years ago

Awesome!

yob commented 12 years ago

Fixed by @3jb in 03e505766