knowah/PyPDF2 — pull request #1 by kushal-kumaran (2012-07-17 05:46:46+00:00)
Title: python 3 support

Hi,

I have changes to make a single source tree work to build both python 2 and python 3 (using 2to3) packages. There are also changes to fix a couple of issues:

- the spec says only the first 16 bytes of the encryption dictionary's U entry must be compared when security handler is revision 3 or greater. I have some pdf files (Producer: [iECCM Version 6.0.0] on Windows Vista) where decryption fails if you compare the entirety of U and real_U in the _authenticateUserPassword function

- I had to make a change in the readObjectHeader function to skip over comments. This was needed to get number of pages in one of my pdf files (same producer as in previous issue). From my limited understanding of the Cross-Reference Table section, it seems like this file is non-conforming to the spec (the byte offset was pointing to the start of the comment before the actual object start), but I'm not sure.

I've tested these changes with a script that writes out decrypted version of some encrypted pdf files using both python2 and python3. If you guys are interested, you can test it out with your collection.