Class PdfSecurityInfo
Describes the security a PDF document carries: whether it is encrypted, which security handler revision (and therefore which algorithm family) protects it, the permissions its author set, the permissions the current session enjoys, and whether the password that opened it was the owner's.
public sealed class PdfSecurityInfo
- Inheritance
-
PdfSecurityInfo
- Inherited Members
Examples
Example: Unlock a protected PDF and keep its security facts.
using LMKit.Document.Pdf;
PdfUnlocker.Unlock("protected.pdf", "s3cret!", "readable.pdf", out PdfSecurityInfo security);
Console.WriteLine($"Encrypted : {security.IsEncrypted}");
Console.WriteLine($"Handler revision : {security.SecurityHandlerRevision}");
Console.WriteLine($"Author forbade : {~security.UserPermissions}");
Console.WriteLine($"Owner password : {security.IsOwnerUnlocked}");
Remarks
Permissions answers for the session: a document opened with its owner password
reports every permission granted. UserPermissions is the author's own /P entry,
whatever password opened the document - the value a document manager keeps beside an unlocked copy
so it can still say what the author forbade. Comparing the two is how IsOwnerUnlocked
tells the owner password from the user (reader) password.
For an unencrypted document IsEncrypted is false, SecurityHandlerRevision
is 0 or less, both permission sets grant everything and IsOwnerUnlocked is false.
Properties
- IsEncrypted
Gets a value indicating whether the document is encrypted (a security handler revision above 0).
- IsOwnerUnlocked
Gets a value indicating whether the document is encrypted and was opened with its OWNER password.
falsefor an unencrypted document, for one opened with the user (reader) password, and for one whose author granted every permission - the two passwords then carry the same rights.
- Permissions
Gets the permission flags the current session enjoys. Every flag is granted when the document is unencrypted or was opened with its owner password.
- SecurityHandlerRevision
Gets the security handler revision: 0 or less for an unencrypted document, 2 for 40-bit RC4, 3 for 128-bit RC4, 4 for 128-bit RC4 or AES-128 (crypt filters), 5 and 6 for AES-256.
- UserPermissions
Gets the permission flags the author set in the encryption dictionary (the
/Pentry), whatever password opened the document. Every flag is granted when the document is unencrypted.