Table of Contents

Class PdfEncryptor

Namespace
PdfEngine.Vector.Security
Assembly
PdfEngine.Vector.dll

Protect with a password and Remove Security: a full rewrite of the document, every object read through the source's security handler (object-stream members as ordinary objects), then encrypted per object with a new Standard security handler (Algorithm 1, AES-256 R6 or AES-128 R4) or written in clear. The cross-reference table is written fresh, with a new /ID. Security is only ever changed with the owner password: the author's permissions are not stripped by anyone who merely knows the open password.

public static class PdfEncryptor
Inheritance
PdfEncryptor
Inherited Members

Methods

CountSignatures(PdfVectorDocument)

Signature dictionaries (with a /ByteRange) in the document: each is invalidated by a rewrite.

public static int CountSignatures(PdfVectorDocument document)

Parameters

document PdfVectorDocument

Returns

int

Encrypt(PdfVectorDocument, PdfEncryptionOptions)

Writes a copy of document protected as options says.

public static PdfSecurityRewriteResult Encrypt(PdfVectorDocument document, PdfEncryptionOptions options)

Parameters

document PdfVectorDocument
options PdfEncryptionOptions

Returns

PdfSecurityRewriteResult

Exceptions

ArgumentException

The passwords are unusable (both empty, equal, prohibited characters).

PdfEncryptedDocumentException

The document is encrypted and the owner password is not known.

InvalidOperationException

The document is signed and AllowInvalidatingSignatures is false.

IsOwnerKnown(PdfVectorDocument, string?)

True when the security of document may be changed: it is not encrypted, it was opened with full rights, or ownerPassword is its owner password.

public static bool IsOwnerKnown(PdfVectorDocument document, string? ownerPassword)

Parameters

document PdfVectorDocument
ownerPassword string

Returns

bool

RemoveSecurity(PdfVectorDocument, string?, bool)

Writes an unencrypted copy. Allowed when the document was opened with its owner password (or as a public-key recipient with every permission), or when ownerPassword proves the owner password now.

public static PdfSecurityRewriteResult RemoveSecurity(PdfVectorDocument document, string? ownerPassword = null, bool allowInvalidatingSignatures = false)

Parameters

document PdfVectorDocument
ownerPassword string
allowInvalidatingSignatures bool

Returns

PdfSecurityRewriteResult

Exceptions

PdfEncryptedDocumentException

The owner password is not known or is wrong.