Table of Contents

Property Password

Namespace
DocWright.Formats.Pdf
Assembly
DocWright.Formats.Pdf.dll

Password

Gets or sets the password used to open an encrypted PDF, or null.

public string? Password { get; set; }

Property Value

string

Remarks

Either the user or the owner password opens the document; DocWright tries the user password first and falls back to the owner's, which is what makes a file with an owner password but no user password open with no password at all — the common shape for a document that is merely permission-restricted.

Supplying a password for an unencrypted PDF is harmless and ignored. Omitting one for an encrypted PDF that does not open with the empty password raises InvalidPasswordException; a security handler DocWright does not implement raises DocumentEncryptedException. Neither message repeats the value. This is the same vocabulary the DOCX path uses, deliberately.

A string rather than a SecureString, for the reason DocumentReadOptions.Password already records: SecureString is documented by the platform as offering no protection off Windows, and every cryptographic API this feeds takes a byte array anyway. DocWright zeroes the key material it derives; it cannot zero the caller's string.