Repair PDF
Repair PDF is an API that fixes a PDF that won't open or says "the file is damaged": it rebuilds its internal structure (the index that says where each page is) and returns a clean PDF with everything that could be recovered.
How it works
You send the PDF and get back another one with its structure rebuilt. If the file had no problems, you get an equivalent copy. The response tells you whether it found something to fix (repaired) and how many pages come out (pages).
Honest note: it repairs the PDF's structure, not its content. If the file was cut off halfway through a download, the pages whose data never got saved can't be made up: you get back the ones that are there, and pages tells you how many. If only the end of the file is missing (the most typical case when a download is cut off just short), you usually get almost everything. If the PDF has a password, remove it first with Unprotect PDF. If nothing can be recovered, we tell you and the credit isn't charged.
All you need
- Your API key. Create it in your dashboard with "+ Create key".
- In your automation platform, an "HTTP Request" step (n8n, Make, Zapier, Pipedream…).
How to use it in n8n
- Method:
POST· URL:https://api.cofferdock.com/pdf-repair - Send Headers:
x-api-key= your key - Send Body: binary file (in n8n: "n8n Binary File")
- In Options → Response → Response Format: choose File
Options
There are none: you send the PDF and that's it. It costs 1 credit per call, and if nothing can be recovered, it isn't charged.
API overview
- Endpoint:
POST https://api.cofferdock.com/pdf-repair - Auth: header
x-api-key: YOUR_KEY. - Input: raw PDF, or JSON
{ "file": "<base64>" }. The%PDF-marker must appear in the first KB of the file. - Engine: qpdf. When it opens a PDF whose index (xref) is broken or missing, it rebuilds it by reading the file object by object and writes a new one.
- Errors:
400if it doesn't look like a PDF or has a password;422if nothing can be recovered (the credit is returned);503withRetry-Afterif the server is busy. - Limits: 20 requests/min per IP. PDF up to 20 MB (50 MB on Business and Scale). 1 call = 1 credit.
Options
| Option | Default | Description |
|---|---|---|
output | json | json (the PDF in base64), pdf or binary (the PDF itself) or url (a 15-minute download link). With a raw PDF, it returns the PDF by default. |
Example
curl -X POST "https://api.cofferdock.com/pdf-repair" \
-H "x-api-key: YOUR_KEY" -H "Content-Type: application/pdf" \
--data-binary @damaged.pdf \
--output repaired.pdf
Response
{ "success": true, "pdf": "JVBERi0xLjQK...", "mime_type": "application/pdf",
"meta": { "repaired": true, "pages": 19,
"warnings": ["input.pdf: file is damaged", "input.pdf: can't find startxref"],
"warnings_total": 4, "original_size_bytes": 2412345, "size_bytes": 2301120,
"used": 12, "remaining": 488 } }
What you get back
meta.repaired is true if something was broken and got worked around, and false if the PDF was fine. meta.pages is the page count of the result: compare it with what you expected. meta.warnings are qpdf's technical notices (in English, up to 10), in case you want to keep them or see what was broken. With a raw PDF, the PDF comes back directly and these values travel in the X-Pdf-Pages and X-Pdf-Repaired headers.