Skip to main content

Encrypt PDFs

Encrypt and password protect your PDF document using the pdf endpoint.

Encrypting and password protecting a PDF is a breeze using The DynamicPDF API's pdf endpoint. Setting password protection and encrypting a PDF requires only a few lines of JSON or a few lines of code if using a client library. The following examples illustrate adding security to a PDF via a direct call to the pdf endpoint.


Check out Getting Started and Task Roadmap if you are new to The DynamicPDF API.


Refer to the documentation outlining security (JSON Instructions Schema - Security).


The DynamicPDF API supports AES-256, AES-128, and RC4-128 encryption.

Calling Endpoint Directly

"creator":"DynamicPDF Cloud Api",

Run In Postman

Calling Endpoint Using Client Library

The following example illustrates adding security to a PDF using the client libraries.


See Instructions Overview for more information on The DynamicPDF API and security.

public static Pdf SecurityExample(String basePath) {
Pdf pdf = new Pdf();
PdfResource pdfResource = new PdfResource(basePath + "DocumentA.pdf");
Aes256Security sec = new Aes256Security("myuser", "mypassword");
sec.AllowCopy = false;
sec.AllowPrint = false;
pdf.Security = sec;
return pdf;
Source: InstructionsExample.cs

The pdf endpoint takes a JSON instructions document that provides instructions for creating, transforming, merging, and formatting inputs into a combined PDF. Refer to documentation on the instructions schema for information on how to use the pdf endpoint.