Flatten PDF API

Convert fillable PDF forms into static, non-editable documents.

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);910  form.append("jsonResponse", "false");11  form.append("metadata", JSON.stringify({12    author: "John Doe",13    documentType: "Contract",14  }));1516  const res = await fetch("https://api.pdfgate.com/forms/flatten", {17    method: "POST",18    body: form,19    headers: { Authorization: "Bearer YOUR_API_KEY" },20  });2122  if (res.status === 201) {23    const buf = Buffer.from(await res.arrayBuffer());24    await fs.writeFile("flattened.pdf", buf);25  } else {26    const text = await res.text();27    console.error(text);28  }29})();
720,000+Documents processed monthly
1,300+Developers using the API
1.6sAverage processing time
99.9%Uptime

Flatten PDF API Overview

The Flatten PDF API allows you to convert interactive PDF form fields into static content as part of an automated document workflow. It is designed for scenarios where filled forms need to be finalized before being shared, stored, or printed.

Flattening a PDF ensures that form values become part of the document layout and can no longer be modified. This is commonly used after form submission to preserve the data exactly as entered and to prevent further changes to the document.

This endpoint can be used on its own or combined with other PDFGate endpoints. A typical workflow includes generating a PDF form, collecting user input, flattening the form to lock in the data, and optionally applying security or compression before distribution.

The Flatten PDF API is well suited for SaaS platforms, internal tools, and document automation systems that require consistent, repeatable form finalization without relying on manual PDF processing.

Useful Guides

View All Guides ↗

API Parameters

File

File

The PDF file you want to flatten. 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.

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