Skip to content

PDF permission retrieval #2391

@stefan6419846

Description

@stefan6419846

When looking at #2389, I stumbled upon some oddities about how PDF permissions are handled/exposed (#2389 (comment)):

  • While we have PdfReader.decode_permissions (introduced in ENH: Extract document permissions #320), we do not expose the corresponding permissions publicly, but only through PdfReader._encryption.values.
  • It is a bit confusing to have both the PdfReader._encryption.values.Perms and the PdfReader._encryption.P attributes without any actual documentation.
    • Perms is the permissions dictionary with permission handlers. Our code at
      values.Perms = encryption_entry.get("/Perms", ByteStringObject()).original_bytes
      and
      Perms: bytes
      considers this as bytes instead? (PDF 1.7 section 8.7.3 "Permissions")
    • P is the actual permission integer value. (PDF 1.7 section 3.5.2 "Standard Security Handler")

I tend to argue that providing a human-readable public API for the P permissions might indeed make sense. Relying on PdfReader._encryption might work, but being an internal API, this is not guaranteed to reliably work in the future as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions