PDFs are how the world ships invoices, contracts, research papers, tax forms, and spec sheets — and they are the single worst format to feed an AI model. A PDF is a binary layout description, not a document. Your LLM cannot read it, your scraper cannot parse it, and your automation script cannot edit it without a pile of fragile local libraries.
Agent Media Tools solves that with four small, real HTTP endpoints that turn PDFs into something software can actually use: PDF to Markdown for LLM-ready text, OCR for scanned documents, PDF Pages for extracting or reordering pages, and PDF Form Fill for completing AcroForm fields programmatically. The same operations are exposed as MCP tools, so Claude Desktop or any MCP client can call them without writing glue code.
Everything in this guide is verified against the live API. No fake SDKs, no imagined endpoints — just curl and requests.
| Endpoint | What it does | MCP tool |
|---|---|---|
POST /api/pdf-to-markdown | PDF → clean, LLM-ready markdown | pdf_to_markdown |
POST /api/ocr | Text from scanned PDFs and images | ocr_extract |
POST /api/pdf-pages | Extract, delete, or reorder pages | pdf_pages |
POST /api/pdf-form-fill | Fill form fields, flatten, stamp | pdf_form_fill |
All endpoints accept the file as a multipart upload or as a public url field, and all return JSON. Files up to 25 MB are supported.
RAG pipelines, document summarizers, and legal/finance automation all share the same bottleneck: getting text out of a PDF. /api/pdf-to-markdown extracts the text layer and converts it into clean markdown with headings, lists, and paragraphs preserved — the format your model already knows how to read.
curl -X POST https://agentmediatools.com/api/pdf-to-markdown \ -F "pdf=@annual-report.pdf" \ -F "max_chars=200000"
Pass a public URL instead of uploading, which is handy inside agent loops:
curl -X POST https://agentmediatools.com/api/pdf-to-markdown \ -F "url=https://example.com/files/spec.pdf"
The response includes the markdown plus metadata you can use for downstream decisions:
{
"success": true,
"markdown": "# Annual Report 2025\n\n## Executive Summary\n...",
"text": "# Annual Report 2025 ...",
"engine": "pdftotext",
"pages": 42,
"char_count": 118403,
"word_count": 18952,
"truncated": false
}
max_chars defaults to 120,000 and can be raised to 500,000. If the document is longer, the response sets "truncated": true and appends an HTML comment marker, so your pipeline knows the output is incomplete.
Same call from Python:
import requests
r = requests.post(
"https://agentmediatools.com/api/pdf-to-markdown",
files={"pdf": open("annual-report.pdf", "rb")},
data={"max_chars": "200000"},
)
data = r.json()
print(data["markdown"][:500])
PDF to Markdown is free for 5 conversions per day on the free tier, and paid usage costs 1 credit per conversion after that.
Scanned PDFs and photographed pages have no text layer, so a plain extract returns nothing. The /api/ocr endpoint runs OCR on the document and returns plain text. Feed it a PDF or an image:
curl -X POST https://agentmediatools.com/api/ocr \ -F "file=@scanned-invoice.png"
curl -X POST https://agentmediatools.com/api/ocr \ -F "url=https://example.com/files/contract.pdf"
Response:
{
"success": true,
"text": "INVOICE NO. 1042 ...",
"engine": "tesseract",
"word_count": 312,
"char_count": 1810
}
PDFs run through pdftotext first (with a pdf-parse fallback), and images run through Tesseract. If you need pixel-perfect layout preservation, prefer /api/pdf-to-markdown on PDFs that already have a text layer; reserve OCR for scans.
Sometimes you need a subset of a document — the signature page, the appendix, the first ten pages of a 300-page filing. /api/pdf-pages does three operations with one endpoint, selected by the action field. It accepts 1-based page lists and ranges like 1,3,5-7.
curl -X POST https://agentmediatools.com/api/pdf-pages \ -H "Authorization: Bearer mt_YOUR_AGENT_KEY" \ -F "pdf=@filing.pdf" \ -F "action=extract" \ -F "pages=1,3,5-7"
Delete pages you do not want, or reorder the document entirely (missing pages append at the end):
curl -X POST https://agentmediatools.com/api/pdf-pages \ -H "Authorization: Bearer mt_YOUR_AGENT_KEY" \ -F "pdf=@deck.pdf" \ -F "action=delete" \ -F "pages=4"
For extract, pages=all is allowed. The response returns the new PDF plus a relative download URL — prefix it with https://agentmediatools.com to fetch the file:
{
"success": true,
"action": "extract",
"filename": "a1b2c3d4.pdf",
"downloadUrl": "/downloads/a1b2c3d4.pdf",
"page_count": 5,
"pages": [1, 3, 5, 6, 7]
}
This endpoint requires authentication (a logged-in session or an agent API key) because it produces files on the server.
W-9s, intake forms, NDAs, and license agreements are all AcroForm PDFs with named fields. /api/pdf-form-fill fills those fields from a JSON map, and optionally flattens the result so the values can no longer be edited, stamps a footer, or adds page numbers.
curl -X POST https://agentmediatools.com/api/pdf-form-fill \
-F "pdf=@w9.pdf" \
-F 'fields={"name":"Ada Lovelace","ein":"12-3456789","signature":"Ada L."}' \
-F "flatten=true" \
-F "stamp_text=Generated by agent" \
-F "page_numbers=true"
Python:
import json
import requests
r = requests.post(
"https://agentmediatools.com/api/pdf-form-fill",
files={"pdf": open("w9.pdf", "rb")},
data={
"fields": json.dumps({"name": "Ada Lovelace", "ein": "12-3456789"}),
"flatten": "true",
},
)
print(r.json()["downloadUrl"])
Checkboxes, dropdowns, and radio groups are handled by type. The response tells you exactly what happened:
{
"success": true,
"filename": "f0e1d2c3.pdf",
"downloadUrl": "/downloads/f0e1d2c3.pdf",
"filled_fields": ["name", "ein"],
"missing_fields": ["signature"],
"available_fields": ["name", "ein", "signature", "date"],
"flattened": true
}
Do not know the field names? Hit POST /api/pdf-list-fields with the same PDF to enumerate every field and its type before filling.
Every endpoint in this post is also a first-class MCP tool: pdf_to_markdown, ocr_extract, pdf_pages, pdf_form_fill, plus merge_pdfs for combining documents (covered in our merge-PDFs guide). Point any MCP client at the hosted server, and your assistant can convert a PDF to markdown, extract a page range, or fill a form as a native tool call — no REST plumbing in your prompt.
An email arrives with a scanned 12-page contract attached. The agent calls ocr_extract (or /api/ocr) and gets the full text.
The agent sends the text to its LLM, which extracts the parties, dates, and key clauses into JSON.
The agent fills a standard signature page with pdf_form_fill, flattens it, and calls pdf_pages to append it to the original document.
The finished PDF is delivered via /downloads/... — no desktop software, no PDF library installs, no sign-up ceremony beyond a free API key.
The APIs are free to start. PDF to Markdown allows 5 free conversions per day, then costs 1 credit per successful conversion. OCR and form fill are public utilities protected by burst limits. PDF page operations require a logged-in session or agent key and use the account's normal request limits. For authenticated REST calls, send an agent key (prefixed mt_) as Authorization: Bearer mt_....
The entire toolbox runs on one key and one account — the same credentials that unlock image generation, video, scraping, and 70+ other tools.
Whether you are building a RAG pipeline, automating paperwork, or teaching an agent to read contracts, these four endpoints remove the worst part of the job: getting the document into a form software can use. No local dependencies, no model training, just HTTP.
Run the same tools in the browser, or call them from your agent with an API key.
Open toolbox