Click or drag to resize
Pdftools logo

Encryption Class

The parameters to encrypt PDF documents

PDF document can be encrypted to protect content from unauthorized access. The encryption process applies encryption to all streams (e.g. images) and strings, but not to other items in the PDF document. This means the structure of the PDF document is accessible, but the content of its pages is encrypted.

The standard security handler allows access permissions and up to two passwords to be specified for a document: A user password (see UserPassword) and an owner password (see OwnerPassword).

The following list shows the four possible combinations of passwords and how an application processing such a PDF document behaves:

  • No user password, no owner password (no encryption):

    Everyone can read, i.e. no password required to open the document. Everyone can change security settings.

  • No user password, owner password:

    Everyone can read, i.e. no password required to open the document. Access permissions are restricted (unless the owner password is provided). Owner password required to change security settings.

  • User password, no owner password:

    User password required to read. All access permissions are granted.

  • User password, owner password:

    User or owner password required to read. Access permissions are restricted (unless the owner password is provided). Owner password required to change security settings.

Since encryption is not allowed by the PDF/A ISO standards, PDF/A documents must not be encrypted.

Inheritance Hierarchy
SystemObject
  PdfTools.InternalNativeBase
    PdfTools.InternalNativeObject
      PdfTools.PdfEncryption

Namespace: PdfTools.Pdf
Assembly: PdfTools (in PdfTools.dll) Version: 1.5.0+84bd4d36da7e2449ee09fddee89e23a99b6ffcca
Syntax
C#
public class Encryption : NativeObject

The Encryption type exposes the following members.

Constructors
 NameDescription
Public methodEncryption 
Top
Properties
 NameDescription
Public propertyOwnerPassword

The owner password

This password is sometimes also referred to as the author’s password. This password grants full access to the document. Not only can the document be opened and read, it also allows the document's security settings, access permissions, and passwords to be changed.

If the password contains characters that are not in the Windows ANSI encoding (Windows Code Page 1252), the output document's compliance level is automatically upgraded to PDF version 1.7. This is because older PDF versions do not support Unicode passwords.

Public propertyPermissions

The access permissions granted when opening the document

The operations granted in a PDF document are controlled using permission flags. In order to set permission flags, the PDF document must be encrypted and have an owner password.

The restricted permissions apply whenever the document is opened with a password other than the owner password. The owner password is required to initially set or later change the permission flags.

When opening an encrypted document, the access permissions for the document can be read using Permissions. Note that the permissions might be different from the "Document Restrictions Summary" displayed in Adobe Acrobat.

Public propertyUserPassword

The user password

This password protects the document against unauthorized opening and reading.

If a PDF document is protected by a user password, it cannot be opened without a password. The user or, if set, owner password must be provided to open and read the document.

If a document is not protected by a user password, it can be opened by without a password, even if an owner password is set.

If the password contains characters that are not in the Windows ANSI encoding (Windows Code Page 1252), the output document's compliance level is automatically upgraded to PDF version 1.7. This is because older PDF versions do not support Unicode passwords.

Top
Methods
 NameDescription
Public methodEquals
(Inherited from NativeObject)
Public methodGetHashCode
(Inherited from NativeObject)
Public methodSetPermissions

Set the owner password and access permissions.

Only the given permissions are granted when opening the document. To the owner of the document, all permissions are granted. For this, the document must be opened by specifying the owner password (see OwnerPassword).
Top
See Also