Pdf.co API
PDF generation and parsing (HTML-to-PDF, extraction) via API.
What it does
PDF.co is a document-processing API: convert PDF to and from text, JSON, CSV, XML, HTML and images; merge, split and reorder pages; fill and read PDF forms; add text/images/watermarks; OCR scanned documents; extract tables; and read/generate barcodes.
Base URL
Authentication
Sign up for an API key and send it as the x-api-key header. Most endpoints take a JSON body with a file url (or you upload first via /file/upload/get-presigned-url).
Code examples
curl -s -X POST https://api.pdf.co/v1/pdf/convert/to/text \
-H "x-api-key: $PDFCO_KEY" -H "Content-Type: application/json" \
-d '{"url":"https://example.com/invoice.pdf","inline":true}'import requests
r = requests.post("https://api.pdf.co/v1/pdf/convert/from/html",
headers={"x-api-key": KEY},
json={"html": "<h1>Hello</h1>", "name": "out.pdf"}, timeout=60)
body = r.json()
print(body["url"] if not body["error"] else body["message"])Rate limits & quotas
Free tier: a monthly credit allowance (a few hundred credits; each operation costs credits by size/complexity), with output files hosted temporarily on PDF.co’s storage (download them promptly). Large jobs should use async: true and poll the job endpoint. Over the credit limit returns an error with error: true.
Key response fields
| error | Boolean — always check first (HTTP may be 200) |
| url | URL of the generated output file (temporary) |
| body | Inline result when inline: true (e.g. extracted text) |
| remainingCredits | Your credit balance after the call |
| jobId | For async jobs — poll /job/check |
Common errors
| error:true, 'Unauthorized' | Missing or wrong x-api-key. |
| error:true, 'out of credits' | Monthly free allowance exhausted. |
| error:true, 'Cannot download source file' | The url isn’t publicly reachable — upload it first. |
| (timeout on big files) | Use async:true and the job-polling flow. |
When to use it (and alternatives)
Useful when you need document conversion/extraction/OCR without running your own toolchain (Ghostscript, poppler, Tesseract). For simple HTML-to-PDF you may prefer a library (wkhtmltopdf, Puppeteer) or a lighter service; for signing/e-sign workflows, a dedicated provider.
FAQ
Do I upload the file or give a URL?
Either. If your PDF is already at a public URL, pass it as url. Otherwise call the presigned-upload endpoint, PUT your file, then pass the returned URL to the operation.
How is usage billed?
In credits, not requests. Each operation’s cost scales with page count and complexity (OCR and table extraction cost more). remainingCredits is in every response.
Why is error:true on an HTTP 200?
PDF.co signals failures in the JSON body. Branch on body['error'] and read message before using url.
New to APIs?
Short guides for working with this API — and any other.