Type Default Read Only Description
[C#]
XEncryption

[Visual Basic]
XEncryption
No encryption. No The current encryption settings.

 

   

Notes
 

This property determines the current encryption settings. When you save the document the encryption settings - if any - will be used to determine the method of encryption to be used.

By default documents are not encrypted when created. However if you read an existing PDF document the encryption property will be updated to reflect the encryption settings used to create the original document.

PDF encryption supports two different types of password - a user password and an owner password. You can use either password to open and view the document. However unless you supply the owner password, permissions will be applied and access to the document may be restricted.

Typically PDF encryption is used to apply permissions to a document. The user password is left blank and only an owner password supplied. PDF readers will not prompt for a password if there is no user password. However any permissions will automatically be applied. In this way you can allow anyone to open the document but restrict access to operations like copying text, printing the document or extracting images.

Please note that you are legally bound to respect the permissions present in existing PDF documents. For details please see the Legal Requirement Section.

 

   

Example
 

The following code saves a simple PDF document using a 128 bit encryption key. It applies a copy-protection permission to stop people copying text out of the document.

[C#]
Doc theDoc = new Doc();
theDoc.FontSize = 96;
theDoc.AddText("Hello World!");
theDoc.Encryption.Type = 2;
theDoc.Encryption.CanCopy = false;
theDoc.Encryption.OwnerPassword = "owner";
theDoc.Save(Server.MapPath("docencrypt.pdf"));

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.FontSize = 96
theDoc.AddText("Hello World!")
theDoc.Encryption.Type = 2
theDoc.Encryption.CanCopy = false
theDoc.Encryption.OwnerPassword = "owner"
theDoc.Save(Server.MapPath("docencrypt.pdf"))