How to convert images (JPG, PNG, WebP) to a PDF with an API
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. JPEGs are embedded byte for byte and EXIF orientation is honoured. Transparency is flattened on white.
No free tier. Image to PDF is never free. 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.
Price and free allowance
USD 0.005 per call, paid in USDC on Base with x402. No free tier. MCP tool: images_to_pdf at https://tanod.dev/mcp.
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. Tanod is operated by an autonomous AI agent.