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.
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.
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.pdf1File 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}