---
title: "Generate a PDF from images server-side | Nutrient"
canonical_url: "https://www.nutrient.io/guides/document-engine/pdf-generation/from-images/"
md_url: "https://www.nutrient.io/guides/document-engine/pdf-generation/from-images.md"
last_updated: "2026-06-04T17:52:54.627Z"
description: "Learn how to convert images to PDF using Document Engine. Follow our step-by-step guide for seamless document creation."
---

# Generate a PDF from images

This guide will take you through the process of generating a PDF using one or more images.

## Using document conversion

This requires you to license [Image Documents](https://www.nutrient.io/sdk/web/).

Your first option for converting an image to a PDF is to upload it directly to Document Engine. This works if you only want to create a PDF from a single image. The following example illustrates this using a PNG file. To create a new document from a PNG file, `POST` its contents to [`/api/documents`](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Documents/operation/upload-document):

**Request**

### SHELL

```shell

curl -X POST http://localhost:5000/api/documents \
  -H "Authorization: Token token=<API token>" \
  -F file=@/path/to/image.png

```

### HTTP

```http

POST /api/documents HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="file"; filename="image.png"
Content-Type: image/png

<PNG data>
--customboundary--

```

**Response**

```http

HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": {
    "document_id":...,
    "errors": [],
    "sourcePdfSha256":...,
    "title": "..."
  }
}

```

The image will automatically be converted and can be downloaded as a PDF using the returned document ID.

## Using PDF Generation

This requires you to license [PDF Generation](https://www.nutrient.io/sdk/solutions/generation/).

Your second option is to use PDF Generation. This allows you to put as many images as you want into a single PDF by adding the images to an HTML page and uploading it to Document Engine.

### Document content

You can arrange your images in the HTML like in the following example:

```html

<!DOCTYPE html>
<html>
  <body>
    <img src="my-image-1.png" width="100%">
    <img src="my-image-2.png" width="100%">
  </body>
</html>

```

### PDF Generation

Next, send the above HTML and the images you want to include to Server for generation. Use the [`/api/documents`](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Documents/operation/upload-document) endpoint, sending the [PDF Generation schema](https://www.nutrient.io/guides/document-engine/pdf-generation/from-html/schema.md) with the HTML file from above. Make sure you also supply the images here:

### CURL

```bash

curl -X POST http://localhost:5000/api/documents \
  -H 'Authorization: Token token=<API token>' \
  -F document_id=image-document \
  -F generation='{
    "html": "page.html",
    "assets": [
      "my-image-1.png",
      "my-image-2.png"
    ]
  }' \
  -F page.html=@/path/to/page.html \
  -F my-image-1.png=@/path/to/my-image-1.png \
  -F my-image-2.png=@/path/to/my-image-2.png

```

### HTTP

```http

POST /api/documents HTTP/1.1
Authorization: Token token=<API token>
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="document_id";

image-document
--customboundary
Content-Disposition: form-data; name="generation";
Content-Type: application/json

{
  "html": "page.html",
  "assets": [
    "my-image-1.png",
    "my-image-2.png"
  ]
}
--customboundary
Content-Disposition: form-data; name="page.html" filename="page.html";
Content-Type: text/html

<HTML data>
--customboundary
Content-Disposition: form-data; name="my-image-1.png" filename="my-image-1.png";
Content-Type: text/html

<PNG data>
--customboundary
Content-Disposition: form-data; name="my-image-2.png" filename="my-image-2.png";
Content-Type: text/html

<PNG data>
--customboundary

```

After performing the above `curl` command, you can view the generated document in the Document Engine dashboard at http://localhost:5000/dashboard/documents/image-document![A PDF showing two images](@/assets/guides/document-engine/pdf-generation/image-document.png)
---

## Related pages

- [Generate Word documents](/guides/document-engine/pdf-generation/from-word-template.md)
- [Preview document thumbnails](/guides/document-engine/pdf-generation/thumbnail-preview.md)
- [Server-side PDF generation](/guides/document-engine/pdf-generation.md)

