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.

tip

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

info

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

info

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

Calling Endpoint Directly

{
"author":"CeteSoftware",
"creator":"DynamicPDF Cloud Api",
"security":{
"userPassword":"myuser",
"ownerPassword":"mypassword",
"allowCopy":false,
"allowEdit":true,
"allowPrint":false,
"allowUpdateAnnotsAndFields":true,
"allowAccessibility":true,
"allowFormFilling":false,
"allowHighResolutionPrinting":true,
"allowDocumentAssembly":false,
"type":"aes256"
},
"flattenAllFormFields":false,
"retainSignatureFormFields":false,
"inputs":[
{
"resourceName":"fw4.pdf",
"type":"pdf"
}
]
}

Run In Postman

Calling Endpoint Using Client Library

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

info

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");
pdf.AddPdf(pdfResource);
Aes256Security sec = new Aes256Security("myuser", "mypassword");
sec.AllowCopy = false;
sec.AllowPrint = false;
pdf.Security = sec;
return pdf;
}
Source: InstructionsExample.cs
info

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.

   Follow us on social media for latest news!