# POST /v1/document/thumbnails

> Create page images of a document posted as Base64 (DOC, DOCX, PDF, TX, XLSX, RTF or HTML): zoomFactor 10 to 400, page range and PNG, JPG, GIF or BMP format.

- **Product:** ReportingCloud
- **Section:** Documentation
- **Kind:** Endpoint
- **Path:** ReportingCloud > API Reference > Web API > Document > /thumbnails > POST /v1/document/thumbnails
- **2511 words**
- **Web URL:** https://docs.textcontrol.com/reporting-cloud/reference/web-api/document/thumbnails/post/
- **LLMs URL:** https://docs.textcontrol.com/reporting-cloud/reference/web-api/document/thumbnails/post/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/reporting-cloud/reference/web-api/document/thumbnails/post/llms-full.txt

---

`POST` `https://api.reporting.cloud/v1/document/thumbnails`

### Description

Renders the pages of a document as images. The request body is the document as a Base64 string; the query selects the pages (`fromPage` and `toPage`, all pages by default), the size (`zoomFactor`, 100 percent by default) and the image format (`imageFormat`, PNG by default). The response is an array with one Base64 image per page. For a template in the template storage, use [GET /v1/templates/thumbnails](https://docs.textcontrol.com/reporting-cloud/reference/web-api/templates/thumbnails/get/llms-full.txt). See [Thumbnails](https://docs.textcontrol.com/reporting-cloud/document-processing/thumbnails/llms-full.txt).

> Warning
>
> **Document Quota.** Each successful request counts 1 against the document quota. It counts 1 also when it renders several pages. [Plans and Licensing](https://docs.textcontrol.com/reporting-cloud/overview/licensing/llms-full.txt) lists the quota of each plan.

### Examples

#### HTTP

Request:

```bash
curl -u username:password \
  -H "Content-Type: application/json" \
  -d "\"CAcBAA4AAAAAAAAAAAAA...==\"" \
  -X POST "https://api.reporting.cloud/v1/document/thumbnails?zoomFactor=80&fromPage=1&toPage=1"
```

Results:

```json
["iVBORw0KGgoAAAANSUhEUgAAAo...mCC"]
```

#### C#

Request:

```csharp
using System;
using System.IO;
using TXTextControl.ReportingCloud;

class RCSamples
{
    public static void GetDocumentThumbnails()
    {
        ReportingCloud rc = new ReportingCloud(
            "username",
            "password",
            new Uri("https://api.reporting.cloud"));

        // read the document from a file
        byte[] bDocument = File.ReadAllBytes("documents/invoice.tx");

        // create thumbnails of pages 1 and 2 at a zoom factor of 20 percent
        var images = rc.GetDocumentThumbnails(bDocument, 20, 1, 2, ImageFormat.PNG);

        // check, if images are created
        Console.WriteLine(images.Count.ToString() + " image thumbnails have been created.");
    }
}
```

Results:

```text
2 image thumbnails have been created.
```

In an application for .NET or .NET Core, `GetDocumentThumbnails` returns a `List<string>` of Base64 strings. In an application for .NET Framework, it returns a `List<System.Drawing.Image>`.

#### Java

```java
// Example code coming soon.
```

#### Ruby

```ruby
# Example code coming soon.
```

#### PHP

Request:

```php
<?php

require_once __DIR__ . '/vendor/autoload.php';

use TextControl\ReportingCloud\ReportingCloud;

$reportingCloud = new ReportingCloud([
    'api_key' => (string) getenv('REPORTINGCLOUD_API_KEY'),
]);

$sourceFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'sample_invoice.tx';

$arrayOfBinaryData = $reportingCloud->getDocumentThumbnails($sourceFilename, 80, 1, 1, 'PNG');

foreach ($arrayOfBinaryData as $index => $binaryData) {

    $page = $index + 1;

    $destinationFile     = sprintf('sample_invoice_p%d.png', $page);
    $destinationFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $destinationFile;

    file_put_contents($destinationFilename, $binaryData);

    var_dump("Written page {$page} to {$destinationFilename}");
}
```

Results:

```text
string(44) "Written page 1 to /tmp/sample_invoice_p1.png"
```

### Authorization

This endpoint requires a "ReportingCloud-APIKey" or a "Basic" user authorization to access the user account, data and templates. Only one of these two methods is required.

[API Keys](https://docs.textcontrol.com/reporting-cloud/installation/api-keys/llms-full.txt) describes how to create an API key, and [Authentication](https://docs.textcontrol.com/reporting-cloud/document-processing/authentication/llms-full.txt) explains both header forms.

#### ReportingCloud-APIKey

| Header field | Description |
|---|---|
| Authorization | **Required**. A valid ReportingCloud account is required. The Authorization field is constructed as follows: An API key needs to be generated in the portal or with [PUT /v1/account/apikey](https://docs.textcontrol.com/reporting-cloud/reference/web-api/account/apikey/put/llms-full.txt). The authorization method and a space, "ReportingCloud-APIKey ", is then put before the actual API key string. For example: `Authorization: ReportingCloud-APIKey oMDM4MrAqL9QEOpyzupnQW5NjvCNtvE5cVDaaLqxI` |

#### Basic

| Header field | Description |
|---|---|
| Authorization | **Required**. A valid ReportingCloud account is required. The Authorization field is constructed as follows: The user name and password are combined into a string separated by a colon, for example `username:password`. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line. The authorization method and a space, "Basic ", is then put before the encoded string. For example: `Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l` |

### Request Parameters

| Name | Type | Value | Optional |
|---|---|---|---|
| zoomFactor | Integer | An Integer value between 10 and 400 to set the percentage zoom factor of the created thumbnail images. Default value: 100. A value that isn't an integer is ignored, and the default is used. | yes |
| fromPage | Integer | An Integer value of 1 or more that specifies the first page. By default the first page is selected. | yes |
| toPage | Integer | An Integer value that specifies the last page. 0 selects the last page, as leaving it out does. If toPage is less than fromPage, the response body is null. | yes |
| imageFormat | String | A string value that defines the image format of the returned thumbnails. Possible values are PNG, JPG, GIF and BMP, in upper or lower case. By default, the return format is PNG. | yes |

### Request Payload

| Type | Value |
|---|---|
| String | A document encoded as a Base64 string, in a JSON string. Supported formats are DOC, DOCX, PDF, TX, XLSX, RTF and HTML. Data in another format isn't refused: it is rendered as plain text, and the request counts against the document quota. |

### Success Response

| Status | Description |
|---|---|
| 200 | On success, the HTTP status code in the response header is 200 (OK). The response body contains a string array of Base64 encoded images in the selected format. If toPage is less than fromPage, the body is null, and the request counts against the document quota all the same. |

### Error Response

| Status | Description |
|---|---|
| 400 | A 400 (Bad Request) with the plain text "No merge data found in body" is returned, if the request body is empty or is not a JSON string. |
| 400 | A 400 (Bad Request) with the plain text "Template not valid" is returned, if zoomFactor is not between 10 and 400 or fromPage is less than 1. |
| 400 | A 400 (Bad Request) with the plain text "Page numbers not valid" is returned, if fromPage or toPage is greater than the number of pages. |
| 400 | A 400 (Bad Request) with the plain text "The image format is not supported" is returned, if imageFormat is not PNG, JPG, GIF or BMP. |
| 400 | A 400 (Bad Request) with the JSON body {"Message":"The request is invalid."} is returned, if zoomFactor, fromPage or toPage is given without a value. |
| 403 | A 403 (Forbidden) is returned, if the user is not authorized or the document quota is exceeded. |
| 405 | A 405 (Method Not Allowed) is returned, if the request uses another HTTP method than POST. The Allow header of the response names POST. |
| 411 | A 411 (Length Required) is returned, if the request has neither a body nor a Content-Length header. |
| 415 | A 415 (Unsupported Media Type) is returned, if the request has a body but no Content-Type header, or a Content-Type such as text/plain that the endpoint doesn't read. Send Content-Type: application/json. |
| 500 | A 500 (Internal Server Error) is returned, if the request has no Authorization header, an empty one or one that is not the authorization method, a space and the credentials, if the request body is a JSON string that is not valid Base64, or if imageFormat is given without a value. |

**Timeout Limitation.** The pure processing time is limited to a maximum of **60 seconds**. After this period of time, the task is canceled.

A typical document should not take more than 5 seconds. If your request takes longer, reduce the size of the document or the number of pages.

---

## Nearby

- **Previous:** [/v1/document/thumbnails](https://docs.textcontrol.com/reporting-cloud/reference/web-api/document/thumbnails/llms-full.txt)
- **Next:** [Templates](https://docs.textcontrol.com/reporting-cloud/reference/web-api/templates/llms-full.txt)
