- HTML to PDF APIConvert HTML and URLs into PDFsExtract PDF Form Data APIEasily extract data from PDFsWatermark PDF APIAdd custom watermarks to PDFsProtect PDF APISecure your PDFs with passwordCompress PDF APIReduce file size without losing qualityFlatten PDF APIFlatten PDFs to make form permanentDigital Signature APISend documents for signing
- API DocumentationAPI DocumentationFull REST API referenceNodeJS SDKClient library for Node.jsJava SDKClient library for JavaC# SDKClient library for C#PHP SDKClient library for PHPPython SDKClient library for Python
- Pricing
- Contact Us

Protect PDF API
Encrypt and secure PDF documents before distribution.
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})();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
FileThe PDF file you want to protect. You must provide either this or documentId.
Document Id
StringThe ID of a PDF that already exists in your PDFGate account. Use this instead of uploading a file again.
Algorithm
EnumThe encryption algorithm to use. Defaults to AES256. Acceptable values: AES256, AES128.
User Password
StringPassword required to open the protected PDF. If not provided, the document can still be accessed but user-level protection may not apply.
Owner Password
StringOwner password granting full control over the PDF, including the ability to change permissions or remove restrictions.
Disable Print
BoolWhen set to true, prevents the PDF from being printed.
Disable Copy
BoolWhen true, disables copying or extraction of text and images from the document.
Disable Editing
BoolWhen true, prevents modifications to the PDF, such as annotation or content changes.
Encrypt Metadata
BoolDetermines whether the document’s metadata (title, author, keywords, etc.) should be encrypted. Defaults to false.
Json Response
BoolIf it is set to true, the API will return a JSON response instead of the PDF file.
Pre Signed Url Expires In
NumberExpiration time (in seconds) for the generated temporary download URL.
Metadata
ObjectCustom metadata you want to attach to the document.
Start building with PDFGate today
Generate PDFs, send documents for signature, and automate your document workflows in minutes.
Free trial · No credit card required




