Image to PDF
Convert one or more images to a PDF document.
https://api.morphopdf.com/v1/convert/image-to-pdfAuthentication
Retrieve your API Key from Dashboard.
Request Body
Provide images using one of the following methods.
fileFile | File[]One or more image files uploaded via multipart/form-data. Supported formats: JPEG, PNG, WebP, GIF, TIFF
urlsstring[]OptionalArray of public URLs pointing to images. Alternative to file upload.
pageSizestringOptionalDefault: OriginalPage size for the PDF. Options: 'A4', 'Letter', 'Original' (fit page to image dimensions)
marginnumberOptionalDefault: 0Margin around images in pixels.
backgroundColorstringOptionalDefault: #FFFFFFBackground color for the PDF pages (hex format).
fitModestringOptionalDefault: containHow images should fit the page. Options: 'contain' (fit within bounds), 'cover' (fill bounds, may crop), 'fill' (stretch to fit)
imageOrderarrayOptionalArray of objects specifying order and rotation for each image: [{name: 'image.jpg', rotation: 90, order: 0}]
Query Parameters
formatstringOptionalDefault: jsonResponse format. Use 'binary' to receive the PDF directly, or 'json' (default) to receive metadata with a download URL.
Supported Image Formats
This endpoint accepts: JPEG, PNG, WebP, GIF, TIFF
Response
When using format=json (default):
successbooleanIndicates whether the operation completed successfully.
messagestringHuman-readable status message.
fileNamestringName of the generated PDF document.
downloadUrlstringPresigned URL to download the file. Valid for 1 hour.
pageCountnumberNumber of pages in the generated PDF.
originalImageCountnumberNumber of images that were successfully processed.
processingTimenumberTime taken to process the conversion in milliseconds.
pageSizestringPage size used for the PDF (e.g. 'A4').
methodstringConversion method used (e.g. 'sharp').
outputSizenumberSize of the generated PDF in bytes.
failedImagesnumberNumber of images that failed to process.
Binary Response
Add ?format=binary to receive the PDF directly with these headers:
Content-Type: application/pdfContent-Disposition: attachment; filename="images.pdf"
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | INVALID_INPUT | No images provided or invalid image format |
| 401 | AUTHENTICATION_REQUIRED | Missing or invalid API key |
| 413 | FILE_TOO_LARGE | File exceeds maximum size limit |
| 500 | PROCESSING_FAILED | Internal processing error |
/v1/convert/image-to-pdfcurl -X POST "https://api.morphopdf.com/v1/convert/image-to-pdf?format=binary" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@image1.jpg" \
-F "file=@image2.png" \
--output images.pdf{
"success": true,
"message": "File processed successfully",
"fileName": "images.pdf",
"downloadUrl": "https://files.morphopdf.com/sessions/abc123/output/images.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Expires=3600&...",
"pageCount": 3,
"originalImageCount": 3,
"processingTime": 1200,
"pageSize": "A4",
"method": "sharp",
"outputSize": 512000,
"failedImages": 0
}