> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/platform-resources/skill-library/document-skills/document-to-image.md).

# Document To Image

**Document To Image** converts an existing document — PDF, DOCX, XLSX — into one or more raster images (PNG by default), one per page or sheet.

The point is not the file format. It's that many capable models are trained to *see*: layout, position, and visual structure carry meaning that flat extracted text loses. Converting first lets the agent look at a document rather than only read it.

## How it works

1. **Input resolution** — uses `$input` (the previous skill's output), `$agent` (agent-level variables), and `$secret` (vault secrets).
2. **Processing:**
   * Pulls the source file from internal storage using `documentId`.
   * Streams pages/sheets to the rendering engine, respecting `pageLimit`.
   * Encodes each page/sheet as an image and writes it to `outputStorage`.
   * Generates lightweight metadata — page number, sheet name — for each rendered image.
3. **Execution** — blocking, typically completing in one invocation for 50 pages or fewer. Large files may be handed to an async worker, but the skill still behaves as blocking.
4. **Response:**
   * **Success** — an `imagesResult` array, one entry per page/sheet.
   * **Partial** — some pages failed; the error message explains which.
   * **Failure** — unrecoverable errors, such as an unconvertible format, throw a workflow-catchable exception.

<figure><img src="/files/4VIT9FZw3EAsJ32pmIjV" alt="" width="563"><figcaption><p>Document To Image processing flow</p></figcaption></figure>

## Worked example: visually classifying financial statements

A workflow receives a mix of financial documents — PDF tax returns, scanned balance sheets that are also PDFs. The agent needs to classify them: *is this a balance sheet or an income statement?* The visual layout usually answers that faster and more reliably than the text does.

**The problem.** Models that classify well from images can't read a raw PDF the same way. Handing over the file directly wastes the visual cues that make the classification easy.

**The approach.** Put a Document To Image skill between the upload and the classifier. Convert the document to page images, then pass those to a reasoning or classification step.

Set `pageLimit` deliberately — for classification you usually need the first page, not all forty. Every extra page is render time and model cost for information that doesn't change the answer.

<figure><img src="/files/6KQY7WwBJL5J6LYJer2q" alt=""><figcaption><p>Configuring the source document and page limit</p></figcaption></figure>

## Configuration reference

| Field               | Type   | Required | Description                                                          |
| ------------------- | ------ | -------- | -------------------------------------------------------------------- |
| `documentId`        | string | ✅        | The document to convert.                                             |
| `source`            | string | ✅        | `conversation` for a temporary file, `storage` for a persistent one. |
| `sourceStoragePath` | string | —        | The path, when `source='storage'`.                                   |
| `pageLimit`         | number | —        | Maximum pages to convert, starting at page 1.                        |
| `outputStorage`     | string | —        | `conversation` (default) or `storage` — where images are written.    |
| `outputstoragePath` | string | —        | Allowed when `outputStorage='storage'`.                              |
| `name`              | string | —        | Display name for this skill instance.                                |
| `description`       | string | —        | Longer description shown in the builder.                             |

## Output

| Field          | Type           | Always | Description                                   |
| -------------- | -------------- | ------ | --------------------------------------------- |
| `statusCode`   | number         | ✅      | HTTP-like — `200` success, `400`/`500` error. |
| `error`        | string \| null | —      | Populated when `statusCode` is above `200`.   |
| `imagesResult` | array          | ✅      | One entry per converted page/sheet.           |

**Each entry in `imagesResult`:**

| Property     | Type   | Description                                       |
| ------------ | ------ | ------------------------------------------------- |
| `images`     | array  | Each rendered image, as `{ documentId: string }`. |
| `sheetName`  | string | Source sheet name, for spreadsheet input.         |
| `pageNumber` | number | Source page number.                               |

Each rendered image gets its own `documentId`, so downstream skills treat it exactly like any other document.

## Errors

| Error                    | Cause                                           |
| ------------------------ | ----------------------------------------------- |
| `DocumentNotFoundError`  | Invalid or inaccessible `documentId`.           |
| `UnsupportedFormatError` | The file type cannot be converted.              |
| `RenderTimeoutError`     | Exceeded the platform time-box for large files. |

Each surfaces with an error status and a descriptive message.

## Testing in isolation

* **Path** — `/skill-runtime/workflows/nodes/DocumentToImage/execute`
* **Method** — `POST`
* **Body:**

```json
{
  "nodeType": "DOCUMENT_TO_IMAGE",
  "config": { },
  "input": { }
}
```

***

To add this skill to an agent, see [Adding a Skill to the Agent](/agent-builder/build/adding-a-skill-to-the-agent.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.uptiq.ai/platform-resources/skill-library/document-skills/document-to-image.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
