How to get the permissions of a pdf document #2389
-
Probably I am missing it, but I cannot find how to retrieve the permissions of a PDF document, the only option that I see in the documentation is Is there something that will return me all the permissions or a way to get the "permissions_code" so I can pass it to the decode_permissions of the current document that I have loaded? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Update: Starting at version 4.0.0, you can now use Old answerSkimming through the code, there has never been a clean API for this.
According to the PDF docs, the |
Beta Was this translation helpful? Give feedback.
Update: Starting at version 4.0.0, you can now use
reader.user_access_permissions
directly.Old answer
Skimming through the code, there has never been a clean API for this.
reader._encryption.values.Perms
holds the permission handlers (PDF 1.7, section 8.7.3).According to the PDF docs, the
P
key of the encryption dictionary holds the corresponding flags. You can access the flags dictionary by this withreader.decode_permissions(reader._encryption.P)
. Please note that this is an internal attribute, thus this code might break in the future.