Combine receipt photos into one PDF by API
Expense apps collect receipt photos one by one. How to combine them into one PDF with one API call: order, page size, margins, and handling iPhone HEIC photos.
Expense reports, insurance claims and delivery proofs all start the same way: someone takes photos on their phone. The accountant, the insurer or the client wants one PDF. The Image to PDF API does that join in one call.
curl https://api.justapi.tech/v1/pdf/from-images \
-H "Authorization: Bearer ak_live_..." \
-H "Content-Type: application/json" \
-d '{"sources": [{"url": "https://uploads.example.com/r/0412.jpg"}, {"url": "https://uploads.example.com/r/0413.jpg"}, {"url": "https://uploads.example.com/r/0415.jpg"}], "options": {"page_size": "letter", "margin": 18}}'
Order
Pages follow the order of sources. Sort them in your app first, for example by receipt date, then send the list.
Page size and margins
page_size:letterora4for documents people will print.fitmakes every page exactly the size of its photo, which looks best on screen.orientation:auto(the default) turns each page to match its photo, so a landscape receipt gets a landscape page.margin: in points; 18 is a quarter inch and keeps photos off the printer's edge.
On fixed page sizes, each image is scaled down to fit inside the margins, centered, and never enlarged past its own size.
iPhone photos
iPhones save HEIC by default, and phone photos often carry their rotation as a tag. Run them through the image optimization API first: it converts HEIC to JPEG, applies the rotation tag, and resizes to a sensible width. Then pass the results here by file_id:
{ "sources": [{ "file_id": "file_a1..." }, { "file_id": "file_b2..." }], "options": { "page_size": "letter" } }
Resizing to around 1600 pixels wide also keeps a 30-photo PDF to a size email accepts.
Bad images
If one source is not a supported image, the call fails before any work, with unsupported_media_type and the source_index of the bad file. Nothing is charged. Supported: JPEG, PNG, WebP, GIF, TIFF and BMP.
Cost
$0.006 per call at the first tier, for up to 200 images.
The free JPG to PDF tool joins up to 20 images in your browser.