The Flatten PDF endpoint converts an interactive PDF (with fillable form fields or annotations) into a static, non-editable version.
You can flatten a document in two ways: upload a PDF file with form data directly, or provide a documentId referencing an existing file already stored in your account.
By default the entire document is flattened. To flatten only specific form fields, pass their names in fieldNames. Those fields become static page content while every other field stays interactive and fillable.
If a documentId is provided, the API always creates a new flattened file in the database, rather than overwriting the existing one. In that case, the response includes a derivedFrom field (when jsonResponse is set to true), indicating the original document ID from which the flattened file was created.
File type: .pdf
The PDF file to be processed. Used when uploading a new file directly.
The ID of an already uploaded file stored on our server.
Flattens only the listed form fields. Each listed field is rendered as static page content, so its current value stays visible but can no longer be edited, while every other field remains interactive.
Provide it as an array of strings (e.g. ["full_name","email"]).
Radio buttons are addressed by their group name, so all options in the group are flattened together.
If a name does not match any form field in the document, the API responds with a 422 error listing the unknown names.
Default: false
Returns JSON response instead of file stream.
Minimum: 60 seconds
Maximum: 86400 seconds (24 hours)
Use this to control temporary authorized access to files. After this duration, the URL automatically expires and can no longer be used to download the PDF. The value must be provided in seconds.
If you need to generate a new pre-signed URL for an existing document, use the Get Document endpoint.
Sets custom data to your document record.
1curl -X POST "https://api.pdfgate.com/forms/flatten" \2 -H "Authorization: Bearer YOUR_API_KEY" \3 -F "file=@YOUR_FILE.pdf" \4 -F "jsonResponse=false" \5 -F "metadata={\"author\":\"John Doe\",\"documentType\":\"Contract\"}" \6 --output flattened.pdf78# Optional: flatten only specific fields (all others stay interactive)9# by adding: -F 'fieldNames=["full_name","email"]'1File stream1{2 "id" : "6642381c5c61",3 "status" : "completed",4 "fileUrl" : "https://api.pdfgate.com/file/open/:preSignedUrlToken",5 "size" : 1620006,6 "type" : "flattened",7 "derivedFrom" : "68f920bacfe16de217f019as",8 "createdAt" : "2024-02-13T15:56:12.607Z"9}