Skip to main content

Encrypt PDF in COM/ActiveX

Encrypt PDF in COM/ActiveX

PDF documents can be encrypted using DynamicPDF Core Suite.

How to Encrypt PDF​

Aes128Security, Aes256Security, RC4128Security, and RC440Security classes present in ceTe.DynamicPDF.Cryptography namespace can be used to Encrypt PDF.

Below is a list of some security settings which can be set along with passwords while encrypting a PDF document.

  • If accessibility programs should be able to read the documents text and images for the user
  • If the document can be assembled and manipulated by the user
  • If form filling should be allowed by the user
  • If the document can be printed at a high resolution by the user
  • The documents components to be encrypted

Steps for Encrypting a PDF Document​

  1. Create a Document object.
  2. Create a Page object and add it to Document.
  3. Create a RC4128Security object by setting the owner and user password.
  4. Set the required security properties and the security to the Document instance.
  5. Output the Document instance to the current web Page

Sample code - ASP​

Dim MyDocument
Set MyDocument = Server.CreateObject("DynamicPDF.Document")

Dim MyPage
Set MyPage = MyDocument.AddPage()

Dim MySecurity
Set MySecurity = MyDocument.SetRC4128Security("owner", "user")
MySecurity.AllowCopy = False

MyDocument.DrawToWeb

How to Encrypt Existing PDF​

DynamicPDF Core Suite can be used to Encrypt an existing PDF document.

Steps for Encrypting an existing PDF​

  1. Create a Document object with the path to the PDF file.
  2. Create a RC4128Security object by setting the owner and user password.
  3. Set the required security properties and the security to the Document instance.
  4. Output the Document instance to the Browser.

Sample Code - ASP​

Dim MyDocument
Set MyDocument = Server.CreateObject("DynamicPDF.Document")
MyDocument.LoadPdf Server.MapPath("pdf-a.pdf")

Dim MySecurity
Set MySecurity = MyDocument.SetRC4128Security("owner", "user")
MySecurity.AllowCopy = False

MyDocument.DrawToWeb

Getting Started​

DynamicPDF Generator and Merger Information​

More information can be found here:

Available in Other Platforms​

Generator and Merger PDF Libraries are available for .NET and Java platforms. Refer to the respective product pages for more details.