Image to PDF
Converts one or more images into a single PDF document.#
/lmkit/v1/image-to-pdfCreates a PDF where each image occupies a full page, sized to match the image dimensions. Supports JPEG, PNG, BMP, WEBP, GIF, and TIFF formats. Optional parameters control image compression (JPEG quality, encoding method) and the output PDF version (including PDF/A conformance levels). The generated PDF is stored on the server and a file ID is returned. Use the file ID to download the result or pass it to other endpoints (document-to-markdown, pdf-search, pdf-layout) using the 'FileIdentifier' input format. This is a pure document processing operation that does not require an AI model. If processing exceeds the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results. Returns 422 Unprocessable Entity with an ErrorResponse body if the input file cannot be processed. The 'error' field contains one of: 'password_required' (encrypted PDF), 'invalid_format' (not a valid PDF), 'unsupported_security' (unsupported encryption), 'page_error' (content error).
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
sourcesrequired | [] | The list of images to convert into a PDF, in order. Each source can be a base64-encoded image or a file identifier. At least one source is required. Each image becomes a page in the output PDF. |
image_encoding | Encoding for color and grayscale images. 'Jpeg' (default): lossy but compact. 'Deflate': lossless compression. | |
binary_image_encoding | Encoding for 1-bit binary images. 'CcittGroup4' (default): optimal for scanned documents. 'Deflate': lossless compression. | |
jpeg_quality | object (int32) | JPEG quality (1-100). Only applies when image_encoding is 'Jpeg'. Default: 70. |
pdf_version | Output PDF version. Accepted values: 'Pdf14', 'Pdf15', 'Pdf16', 'Pdf17' (default), 'PdfA1b', 'PdfA2b', 'PdfA3b'. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 202 | Accepted | |
| 400 | Bad Request | |
| 404 | Not Found | |
| 422 | Unprocessable Entity | |
| 500 | application/json | Internal Server Error |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/image-to-pdf" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"sources": [
{
"input": "",
"input_format": "Base64EncodedFile"
}
],
"image_encoding": 0,
"binary_image_encoding": 0,
"jpeg_quality": 70,
"pdf_version": 4
}'