Class PdfProtection
- Namespace
- DocToolkit
- Assembly
- DocToolkit.Pdf.dll
The password and permissions applied by Protect(byte[], PdfProtection).
public sealed class PdfProtection
- Inheritance
-
PdfProtection
- Inherited Members
Remarks
The two passwords do different jobs, and mixing them up is the usual mistake.
- UserPassword is needed to open the document. Without it, the file cannot be read at all.
- OwnerPassword is needed to change the restrictions. A document with only an owner password opens for anyone, and the permissions below are what a reader is asked to honour.
Permissions are a request to the reader, not a guarantee. Measured 2026-08-16: a document carrying only an owner password opens with no password at all — that is the PDF specification working as designed, not a defect here. A cooperative reader greys out printing; an uncooperative one need not. If content must not be read, use UserPassword — that is enforced by cryptography rather than by convention.
Every permission defaults to allowed, so adding a password does not silently forbid printing a document that could be printed before.
Properties
AllowAnnotations
Adding or editing annotations is permitted. Defaults to true.
public bool AllowAnnotations { get; init; }
Property Value
AllowAssembly
Inserting, rotating and deleting pages is permitted. Defaults to true.
public bool AllowAssembly { get; init; }
Property Value
AllowCopying
Copying text and graphics out is permitted. Defaults to true.
public bool AllowCopying { get; init; }
Property Value
AllowFormFilling
Filling in form fields is permitted. Defaults to true.
public bool AllowFormFilling { get; init; }
Property Value
AllowHighQualityPrinting
Full-resolution printing is permitted. Defaults to true. Ignored by readers when AllowPrinting is false.
public bool AllowHighQualityPrinting { get; init; }
Property Value
AllowModification
Changing the content is permitted. Defaults to true.
public bool AllowModification { get; init; }
Property Value
AllowPrinting
Printing is permitted. Defaults to true.
public bool AllowPrinting { get; init; }
Property Value
OwnerPassword
The password required to change the permissions below. null or empty means none is set.
public string? OwnerPassword { get; init; }
Property Value
Strength
The cipher to use. Defaults to Aes128 — see that member for why the stronger option is not the default.
public PdfEncryptionStrength Strength { get; init; }
Property Value
UserPassword
The password required to open the document. null or empty means the document opens without one.
public string? UserPassword { get; init; }