Skip to main content

Security

Version: 11.0

Security

Add security to a Document using one of four encryption algorithms (listed below). All four encryption algorithms are contained in the ceTe.DynamicPDF.Cryptography namespace. In general, adding security to a PDF involves the following steps,

  • selecting an encryption algorithm to use,
  • setting user and/or owner passwords, and
  • specifying user access permissions.

Encryption Algorithms​

The following chart lists the four encryption algorithms.

Encryption AlgorithmClassCompatibility
40-bit RC4 EncryptionRC440SecurityPDF 1.1 (Acrobat 3 or later)
128-bit RC4 EncryptionRC4128SecurityPDF 1.4 (Acrobat 5 or later)*
128-bit AES EncryptionAes128SecurityPDF 1.5 (Acrobat 7 or later)
256-bit AES EncryptionAes256Security (FIPS Compliant)PDF 1.5 (Acrobat 10 or later)

NOTE: PDF 1.5 (Acrobat 6 or later) if the UseCryptFilter is set to True (it is false by default)

Document Passwords​

When applying security to a PDF using one of these algorithms, an owner and/or password can be specified. When a user password is specified, the PDF viewer will require this password to be specified prior to opening the PDF document. Leaving the user password blank (by specifying an empty string) will not require a password to open the PDF document. Whether a user password is defined or blank (empty string) the access permissions set on the document will still be applied. When an owner password is specified, the PDF viewer will require this password to be specified if someone attempts to modify the PDF file.

Security Options​

The RC4 40-bit encryption supports four security options:

  • Restrict document printing

  • Restrict document Modification

  • Restrict copying text or graphics from the document

  • Restrict updating or adding text annotations or form fields

The RC4 128-bit encryption supports the four security options above along with the following:

  • Restrict fill in existing form fields

  • Restrict extract text and graphics for accessibility programs

  • Restrict document assembly

  • Restrict high Resolution Printing

  • Encrypt all document contents except Metadata (Acrobat 6 and later compatible)

AES 128-bit and AES 256-bit encryption supports the 9 security options above along with the following:

  • Encrypting only file attachments

Usage (128-bit RC4)​

The following example illustrates how to secure a Document using RC4 128-bit encryption, set the Document to not allow copying of content and to not encrypt the file's Metadata information.

RC4128Security security = new RC4128Security( "owner", "user" );
Security.UseCryptFilter = true;
security.EncryptMetadata = false;
document.Security = security;
Dim MySecurity As RC4128Security = New RC4128Security( "owner", "user" )
MySecurity.UseCryptFilter = True
MySecurity.EncryptMetadata = False
MyDocument.Security = MySecurity

AES Encryption Document Components​

With AES encryption (both 128-bit and 256-bit) there are three Document Component options for encrypting the PDF and those options are handled by the DocumentComponents property of the respective AES encryption class. AES encryption can apply to the following document portions.

Document PortionDescription
Entire Document (EncryptDocumentComponents.All)Encrypts the document, its Metadata and any file attachments.
Entire Document except the Metadata (EncryptDocumentComponents.AllExceptMetadata)Encrypts the document, its Metadata and any file attachments.
Only the Document’s file attachments (EncryptDocumentComponents.OnlyFileAttachments)Encrypts only the document’s file attachments. None of the actual PDF document or Metadata are encrypted. It is important to note here that setting this EncryptDocumentComponents to OnlyFileAttachments will take precedence over any user permissions and cause them to be ignored.