pmaupin / pdfrw

pdfrw is a pure Python library that reads and writes PDFs
Other
1.86k stars 271 forks source link

means to determine that a file is encrypted #224

Open StevanWhite opened 2 years ago

StevanWhite commented 2 years ago

I have discovered that an attempt to alter metadata in an encrypted PDF can result in an unreadable file. It would be really nice to have a way to know beforehand that the file is encrypted, even if other encryption features are not implemented. Then I could avoid damaging the file.

I can see that the file in question has encryption: pdfinfo gives

Encrypted: yes (print:yes copy:yes change:no addNotes:yes algorithm:RC4

It looks like the Info object might have a member Encrypt ... but with this file, it's not set. If it were simply set when the file is encrypted, that would help!