Docs/APIs/Image to PDF

Image to PDF

Combine images into one PDF

OperationalCredits 10 per callp50 1365msDocumentsStar

Overview

The PDF is assembled with pdf-lib. Inputs arrive as multipart file parts (any field name, in form order), or as `image` (base64 data or a URL) followed by the URLs in `urls`. Each file is identified from its first bytes, not its name. URLs are downloaded with a 10 MB limit each and a 20-second timeout and must point to public hosts. More than 20 images, a file over 10 MB or 25 MB in total, or an unsupported format returns an error naming the problem, and no PDF is made.

JPEG and PNG images are embedded as they are: JPEG bytes are copied into the PDF unchanged and PNG pixels are stored losslessly. A JPEG whose EXIF orientation is not upright, and every HEIC, AVIF, WebP, BMP, GIF and TIFF image, is first decoded by APIVerve's image service (ImageMagick) and turned upright; photo formats come back as JPEG at quality 90 and the rest as PNG. Every frame of a GIF or TIFF becomes its own page, animated GIF frames composited as they display. When `quality` is set, every image goes through that step and is re-encoded as JPEG at that quality, with transparency flattened onto white.

With `pageSize` fit, each page measures the image at 96 pixels per inch (0.75 points per pixel) plus the margin on every side, capped at the 200-inch PDF limit. With a4 (595.28 x 841.89 pt), letter (612 x 792 pt) or legal (612 x 1008 pt), the image is scaled up or down to fit inside the margins, keeping its aspect ratio, and centred; orientation auto picks landscape when the image is wider than it is tall. `pageCount` can exceed `imageCount` because of multi-frame files. The Free plan stops at 5 pages and paid plans at 100; going over returns 403 or 400 before anything is stored.

Live Test Image to PDF API →

Endpoint

One host, one path per API. The block below shows this call in four languages; every one of them is the same HTTP request. Making requests covers the timeouts, retries and parameter rules that apply to all of them. The SDKs wrap the same call in a typed client.

POSThttps://api.apiverve.com/v1/imagetopdf
curl -X POST https://api.apiverve.com/v1/imagetopdf \
  -H "x-api-key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "urls": [
    "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=1200",
    "https://images.unsplash.com/photo-1449824913935-59a10b8d2000?w=1200"
  ],
  "pageSize": "a4",
  "orientation": "auto",
  "margin": 10
}'

Replace your_api_key_here with the key from your dashboard. When the inputs arrive as a list rather than one at a time, batch requests run up to 200 of them through this same API in a single call.

Authentication

Send your key in the x-api-key header. That is the only auth step — there is no token exchange and no per-endpoint scope to configure. Authentication covers creating, rotating and revoking keys.

401 is the only auth verdict

A 401 means the key is missing, invalid or expired. A 403 means the key is valid but not permitted here — blocked by a key restriction or an IP allow-list. Running out of credits is a 429.

Parameters

Sent as JSON in the request body. Premium parameters are accepted on every plan but only take effect on plans that include them.

ParameterTypeDescription
imageOptionalstringAn image file (upload one or more as multipart files, up to 20), base64 image data, or a public image URL
urlsOptionalarrayA JSON array of public image URLs, added in order after image. Up to 20 images per call in all
pageSizeOptionalstringPage size: fit makes each page the size of its image; a4, letter and legal fit the image inside the margins
fita4letterlegal
default a4
orientationOptionalstringPage orientation for a4, letter and legal; auto turns each page to match its image. Ignored for fit
autoportraitlandscape
default auto
marginOptionalnumberMargin around each image in millimetres, from 0 to 50
range 0–50
qualityOptionalintegerRe-compress every image as JPG at this quality (1-100) to make the PDF smaller. Omit to keep JPG and PNG images unchanged
range 1–100

Response

Every API returns the same three top-level keys, so one response handler covers your whole integration: status, error and data. Only data changes shape. Response format covers the envelope, the other output formats and how premium fields are withheld.

Sample response
{
  "status": "ok",
  "error": null,
  "data": {
    "pdfName": "7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.pdf",
    "imageCount": 2,
    "pageCount": 2,
    "pageSize": "a4",
    "orientation": "auto",
    "margin": 10,
    "quality": null,
    "size": 483291,
    "expires": 1792400000000,
    "downloadURL": "https://storage.googleapis.com/apiverve/APIData/imagetopdf/7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.pdf?GoogleAccessId=635500398038-compute%40developer.gserviceaccount.com&Expires=1792400000&Signature=SAM…"
  }
}

Response fields

Paths are relative to data. Premium fields are absent rather than zeroed on plans that do not include them, so check for presence instead of comparing to 0.

FieldTypeExampleDescription
pdfNamestring"7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.pdf"File name of the PDF
imageCountnumber2Number of images received
pageCountnumber2Pages in the PDF; more than imageCount when a GIF or TIFF has several frames
pageSizestring"a4"Page size used
orientationstring"auto"Orientation setting used; null for fit
marginnumber10Margin in millimetres
qualityobjectnullJPG quality images were re-compressed at, or null when they were kept unchanged
sizenumber483291Size of the PDF in bytes
expiresnumber1792400000000When the download link expires (Unix time in milliseconds)
downloadURLstring"https://storage.googleapis.com/apiverve/APIData/imagetopdf/7c1e4b9a-2f3d-4e8a-9b6c-5d0a1f2e3c4b.pdf?…"Signed link to download the PDF, valid for 2 days

Errors

Read the HTTP status first, then error for the specific reason. The body names the parameter that has to change. Error handling covers the full status list and which of them are worth retrying.

StatusMeaningWhat to do
400Input was rejectedRead error; it names the parameter.
401Key missing or invalidCheck the header name and the key value.
403Key valid, but not permittedA key restriction or IP allow-list; see key scoping.
429Rate limited, or out of creditsRead error to tell them apart; see rate limits.

Use cases

Receipt and Expense Uploads
Bundle photos of receipts taken on a phone into one PDF for an expense report or an accounting system.
Scanned Document Packs
Turn multi-page TIFF scans or a set of page photos into a single PDF that any viewer can open.
Photo Books and Portfolios
Assemble product shots or portfolio images into a PDF for clients, with consistent paper size and margins.
Form Attachments
Accept images in an upload form and store or forward them as one PDF, the format many back-office systems require.

Other ways to use Image to PDF

Set up Image to PDF on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them — one key, one balance.

Give it to an AI agentConnect over MCP and your agent calls it as a native tool — Claude, Cursor, ChatGPT.VerveKit →Reference →

More in Documents:

Was this page helpful?