Protect PDF API

Encrypt and secure PDF documents before distribution.

NODE.JS
CURL
PYTHON
GO
PHP
JAVA
C#
RUBY
1const fs = require("fs/promises");23(async () => {4  const form = new FormData();56  const bytes = await fs.readFile("YOUR_FILE.pdf");7  const file = new File([bytes], "YOUR_FILE.pdf", { type: "application/pdf" });8  form.append("file", file);9  form.append("ownerPassword", "ownerPassword");10  form.append("userPassword", "userPassword");11  form.append("disablePrint", "true");12  form.append("disableCopy", "true");13  form.append("disableEditing", "true");1415  const res = await fetch("https://api.pdfgate.com/protect/pdf", {16    method: "POST",17    body: form,18    headers: { Authorization: "Bearer YOUR_API_KEY" },19  });2021  if (res.status === 201) {22    const buf = Buffer.from(await res.arrayBuffer());23    await fs.writeFile("protected.pdf", buf);24  } else {25    const text = await res.text();26    console.error(text);27  }28})();
720,000+Documents processed monthly
1,300+Developers using the API
1.6sAverage processing time
99.9%Uptime

Protect PDF API Overview

The Protect PDF API allows you to apply encryption, passwords, and permission rules to PDF documents as part of an automated document workflow. It is designed for use cases where access to PDFs needs to be controlled and sensitive content must be protected before sharing or storage.

Protecting a PDF helps prevent unauthorized access, editing, or copying of document content. This is commonly used to secure documents that contain confidential information, legal data, or internal business materials.

This endpoint can be used on its own or combined with other PDFGate endpoints. A typical workflow includes generating a PDF, applying protection rules to restrict access or permissions, and then distributing the secured document to end users.

The Protect PDF API is well suited for SaaS platforms, internal systems, and document automation workflows that require consistent, programmatic PDF security without manual intervention.

Useful Guides

View All Guides ↗

API Parameters

File

File

The PDF file you want to protect. You must provide either this or documentId.

Document Id

String

The ID of a PDF that already exists in your PDFGate account. Use this instead of uploading a file again.

Algorithm

Enum

The encryption algorithm to use. Defaults to AES256. Acceptable values: AES256, AES128.

User Password

String

Password required to open the protected PDF. If not provided, the document can still be accessed but user-level protection may not apply.

Owner Password

String

Owner password granting full control over the PDF, including the ability to change permissions or remove restrictions.

Disable Print

Bool

When set to true, prevents the PDF from being printed.

Disable Copy

Bool

When true, disables copying or extraction of text and images from the document.

Disable Editing

Bool

When true, prevents modifications to the PDF, such as annotation or content changes.

Encrypt Metadata

Bool

Determines whether the document’s metadata (title, author, keywords, etc.) should be encrypted. Defaults to false.

Json Response

Bool

If it is set to true, the API will return a JSON response instead of the PDF file.

Pre Signed Url Expires In

Number

Expiration time (in seconds) for the generated temporary download URL.

Metadata

Object

Custom metadata you want to attach to the document.

Integrate in minutes

Use your favorite language with simple REST API endpoints, SDKs, and step-by-step developer guides.

Start building with PDFGate today

Generate PDFs, send documents for signature, and automate your document workflows in minutes.

Free trial · No credit card required