AngusJohnson / PdfPageCount

Get PDF file page counts
Boost Software License 1.0
14 stars 6 forks source link

A PDF file that can't be processed #1

Open superflexible opened 9 months ago

superflexible commented 9 months ago

Example.pdf Hello, many thanks for providing this code!

I have a few PDF files that throw a decompression error, although the files are valid and can be viewed fine. I don't think they are encrypted.

I am attaching an example.

Do you think it can be fixed?

Many thanks. Tobias

superflexible commented 9 months ago

Apparently it is encrypted but without a password or something like that?

Can a workaround somehow be found?

AngusJohnson commented 8 months ago

Hi Tobias. Yes it is encrypted (to limit copy permissions) even though no password is required. And unfortunately decryption isn't currently supported because it adds a whole new level of complexity. Nevertheless I've just updated the repository so we're a bit closer to accomplishing this, but there's still quite a way to go. And unfortunately for you, I'm very tied up with another project. Of course you're welcome to contribute decrypt code (since I've mostly covered the PDF specific stuff) but I won't be spending much time on this myself any time soon. Sorry to disappoint.

superflexible commented 8 months ago

Hi Angus, no problem at all, thanks for the information! Maybe I'll have a go at decryption. I worked with AES256 a lot, but of course it would add dependency on another library, or maybe something that ships with Delphi.

AngusJohnson commented 8 months ago

worked with AES256 a lot, but of course it would add dependency on another library, or maybe something that ships with Delphi.

The following code seems to have a very permissive license 😜: https://github.com/stijnsanders/tools/blob/master/crypto/aes.pas

Edit: And adding Cipher Block Chaining that's also needed shouldn't be too difficult.

See also Encryption (Section 3.5) in the PDF Reference Doc.