Table of Contents

Class EncryptionProperties

Namespace
iText.Kernel.Pdf
Assembly
itext.kernel.dll

Allows configuration of output PDF encryption.

public class EncryptionProperties
Inheritance
EncryptionProperties
Inherited Members

Constructors

EncryptionProperties()

public EncryptionProperties()

Fields

encryptionAlgorithm

protected int encryptionAlgorithm

Field Value

int

ownerPassword

protected byte[] ownerPassword

Field Value

byte[]

publicCertificates

protected IX509Certificate[] publicCertificates

Field Value

IX509Certificate[]

publicKeyEncryptPermissions

protected int[] publicKeyEncryptPermissions

Field Value

int[]

standardEncryptPermissions

protected int standardEncryptPermissions

Field Value

int

userPassword

protected byte[] userPassword

Field Value

byte[]

Methods

SetPublicKeyEncryption(IX509Certificate[], int[], int)

Sets the certificate encryption options for the document.

public virtual EncryptionProperties SetPublicKeyEncryption(IX509Certificate[] certs, int[] permissions, int encryptionAlgorithm)

Parameters

certs IX509Certificate[]

the public certificates to be used for the encryption

permissions int[]

the user permissions for each of the certificates The open permissions for the document can be ALLOW_PRINTING , ALLOW_MODIFY_CONTENTS , ALLOW_COPY , ALLOW_MODIFY_ANNOTATIONS , ALLOW_FILL_IN , ALLOW_SCREENREADERS , ALLOW_ASSEMBLY and ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing them

encryptionAlgorithm int

the type of encryption. It can be one of STANDARD_ENCRYPTION_40 , STANDARD_ENCRYPTION_128 , ENCRYPTION_AES_128 or ENCRYPTION_AES_256. Optionally DO_NOT_ENCRYPT_METADATA can be ORed to output the metadata in cleartext. EMBEDDED_FILES_ONLY can be ORed as well. Please be aware that the passed encryption types may override permissions: STANDARD_ENCRYPTION_40 implicitly sets DO_NOT_ENCRYPT_METADATA and EMBEDDED_FILES_ONLY as false; STANDARD_ENCRYPTION_128 implicitly sets EMBEDDED_FILES_ONLY as false;

Returns

EncryptionProperties

this EncryptionProperties

Remarks

Sets the certificate encryption options for the document.

An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate.

SetStandardEncryption(byte[], byte[], int, int)

Sets the encryption options for the document.

public virtual EncryptionProperties SetStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)

Parameters

userPassword byte[]

the user password. Can be null or of zero length, which is equal to omitting the user password

ownerPassword byte[]

the owner password. If it's null or empty, iText will generate a random string to be used as the owner password

permissions int

the user permissions. The open permissions for the document can be ALLOW_PRINTING , ALLOW_MODIFY_CONTENTS , ALLOW_COPY , ALLOW_MODIFY_ANNOTATIONS , ALLOW_FILL_IN , ALLOW_SCREENREADERS , ALLOW_ASSEMBLY and ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing them

encryptionAlgorithm int

the type of encryption. It can be one of STANDARD_ENCRYPTION_40 , STANDARD_ENCRYPTION_128 , ENCRYPTION_AES_128 or ENCRYPTION_AES_256. Optionally DO_NOT_ENCRYPT_METADATA can be OEed to output the metadata in cleartext. EMBEDDED_FILES_ONLY can be ORed as well. Please be aware that the passed encryption types may override permissions: STANDARD_ENCRYPTION_40 implicitly sets DO_NOT_ENCRYPT_METADATA and EMBEDDED_FILES_ONLY as false; STANDARD_ENCRYPTION_128 implicitly sets EMBEDDED_FILES_ONLY as false;

Returns

EncryptionProperties

this EncryptionProperties