How to convert images (JPG, PNG, WebP) to a PDF with an API
Updated 2026-11-18
Use when a set of images, such as photographed pages, must be combined into one PDF. Add output=url for a 24 h link.
From an MCP client, add https://tanod.dev/mcp and call images_to_pdf; calls are paid per use with x402, no key or signup.
POST a list of images to /v1/pdf/from-images. It returns one PDF with one page per image.
Request
images is 1 to 30 entries, each {"url": ...} or {"image_base64": ...} (PNG, JPEG or WebP, each up to 40 megapixels). page_size is fit (each page is its image's size, default), a4 or letter; orientation (auto, portrait or landscape) and margin in points apply to a4 and letter.
curl -s -X POST https://tanod.dev/v1/pdf/from-images \
-H 'content-type: application/json' \
-d '{"images": [{"url": "https://tanod.dev/icon.png"}], "page_size": "a4"}'The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:
curl -s -X POST https://tanod.dev/v1/pdf/from-images \
-H 'content-type: application/json' \
-d '{"images": [{"url": "https://tanod.dev/icon.png"}], "page_size": "a4"}' \
| jq -r '.file.data_base64' | base64 -d > images.pdfResponse
{
"operation": "from-images",
"input_bytes": 2183,
"input_pages": 1,
"images": 1,
"page_size": "a4",
"file": {
"name": "images.pdf",
"content_type": "application/pdf",
"bytes": 3285,
"pages": 1,
"data_base64": "JVBERi0xLjMKJeLj"
},
"output_bytes": 3285,
"untrusted_content": true
}Limits and caveats
Image handling. Upright RGB and grayscale JPEGs are embedded byte for byte; other JPEGs are decoded to pixels, with EXIF orientation honoured. Transparency is flattened on white.
No free tier. An unpaid call returns a 402 with payment requirements. Output over 15 MB is a 413 and is not charged.
Doing this by hand? Use the free JPG to PDF converter in your browser.
Download link. Add "output": "url" to the request and the file is stored for 24 hours and returned as a link (url, expires_at, sha256) instead of base64, which keeps it out of your context window. The price is the same. How the links work.
Price and free allowance
USD 0.005 per call, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. No free tier. MCP tool: images_to_pdf at https://tanod.dev/mcp.
Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/docs?via=images-to-pdf-api as a custom connector (steps), then ask in plain words, for example "Combine these photos of pages into one PDF." Eligible Claude.ai connectors use a shared daily docs allowance; ordinary MCP calls are paid. Outside that allowance, a call needs an x402 payment, which these clients can make.
Related guides: How to convert PDF pages to PNG or JPEG images with an API, How to merge PDF files with an API, How to compress an image to a target file size with an API. Back to tanod.dev or the guide index. Results are automated and heuristic.