# GET /v1/templates/thumbnails

> Create PNG, JPG, GIF or BMP images of the pages of a stored template with the templateName, zoomFactor, fromPage, toPage and imageFormat parameters.

- **Product:** ReportingCloud
- **Section:** Documentation
- **Kind:** Endpoint
- **Path:** ReportingCloud > API Reference > Web API > Templates > /thumbnails > GET /v1/templates/thumbnails
- **3481 words**
- **Web URL:** https://docs.textcontrol.com/reporting-cloud/reference/web-api/templates/thumbnails/get/
- **LLMs URL:** https://docs.textcontrol.com/reporting-cloud/reference/web-api/templates/thumbnails/get/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/reporting-cloud/reference/web-api/templates/thumbnails/get/llms-full.txt

---

`GET` `https://api.reporting.cloud/v1/templates/thumbnails`

### Description

Renders the pages of a template in the template storage as images. The query names the template and 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 document that isn't stored, use [POST /v1/document/thumbnails](https://docs.textcontrol.com/reporting-cloud/reference/web-api/document/thumbnails/post/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 \
  -X GET "https://api.reporting.cloud/v1/templates/thumbnails?templateName=sample_invoice.tx&zoomFactor=80&fromPage=1&toPage=1"
```

Results:

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

#### C#

Request:

```csharp
using System;
using System.Collections.Generic;
using System.Drawing;
using TXTextControl.ReportingCloud;

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

        try
        {
            List<Image> lstThumbnails = rc.GetTemplateThumbnails(
                templateName, 20, 1, 0, ImageFormat.PNG);

            foreach (Image img in lstThumbnails)
            {
                string sImageFilename = Guid.NewGuid().ToString() + ".jpg";
                img.Save(sImageFilename, System.Drawing.Imaging.ImageFormat.Jpeg);

                Console.WriteLine("Image saved to: " + sImageFilename);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("An error occurred: " + e.Message);
        }
    }
}
```

Results:

```text
Image saved to: c54a1989-b8bf-4811-ad3f-22c394317daf.jpg
```

The sample is for .NET Framework, where `GetTemplateThumbnails` returns a `List<System.Drawing.Image>`. In an application for .NET or .NET Core, it returns a `List<string>` of Base64 strings, which `Convert.FromBase64String` decodes.

#### Java

Request:

```java
import com.textcontrol.reportingcloud.ImageFormat;
import com.textcontrol.reportingcloud.ReportingCloud;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

public class ReportingCloudSample {
    public static void main(String[] args) throws IOException {
        ReportingCloud r = new ReportingCloud("username", "password");
        List<byte[]> thumbnails = r.getTemplateThumbnails("sample_invoice.tx", 50, 1, 0, ImageFormat.JPG);

        for (int i = 0; i < thumbnails.size(); ++i) {
            String fileName = "thumbnail_" + String.format("%02d", i) + ".jpg";
            Files.write(Paths.get(fileName), thumbnails.get(i));
            System.out.println("Thumbnail image was written to " + fileName + ".");
        }
    }
}
```

Results:

```text
Thumbnail image was written to thumbnail_00.jpg.
```

#### Ruby

Request:

```ruby
#!/usr/bin/env ruby

require "txtextcontrol/reportingcloud"
require "base64"

reporting_cloud = TXTextControl::ReportingCloud::ReportingCloud.new("username", "password")
thumbnails = reporting_cloud.get_template_thumbnails("sample_invoice.tx", 50, 1, 0, :jpg)

i = 0
while i < thumbnails.length do
  file_name = "thumbnail_#{i.to_s.rjust(2, "0")}.jpg"
  File.open(File.dirname(__FILE__) + "/#{file_name}", 'wb') do |f|
    f.write(Base64.strict_decode64(thumbnails[i]))
  end
  puts "Thumbnail image was written to #{file_name}."
  i += 1
end
```

Results:

```text
Thumbnail image was written to thumbnail_00.jpg.
```

#### PHP

Request:

```php
<?php

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

use TextControl\ReportingCloud\ReportingCloud;

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

$templateName = 'sample_invoice.tx';

$arrayOfBinaryData = $reportingCloud->getTemplateThumbnails('sample_invoice.tx', 100, 1, 1, 'PNG');

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

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

    file_put_contents($destinationFilename, $binaryData);

    var_dump("{$templateName} was written to {$destinationFilename}");
}
```

Results:

```text
string(59) "sample_invoice.tx was written to /tmp/sample_invoice_p0.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 |
|---|---|---|---|
| templateName | String | The filename of the template in the template storage. The name is matched case-insensitively. | no |
| zoomFactor | Integer | An Integer value between 10 and 400 to set the percentage zoom factor of the created thumbnail images. At 100, a page is rendered at 96 dpi. Default value: 100. | yes |
| fromPage | Integer | An Integer value that specifies the first page, from 1 to the number of pages. By default the first page is selected. | yes |
| toPage | Integer | An Integer value that specifies the last page, up to the number of pages. 0 selects the last page, and so does leaving it out. | 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 |

### 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, one per page, in page order. If fromPage is greater than toPage, the body is null, and the request still counts against the document quota. |

### Error Response

| Status | Description |
|---|---|
| 400 | A 400 (Bad Request) is returned, if the template doesn't exist in the template storage or templateName is empty, if zoomFactor is not between 10 and 400 or fromPage is less than 1 ("Template not valid"), if fromPage or toPage is past the last page ("Page numbers not valid"), if imageFormat is not one of the possible values ("The image format is not supported"), or if zoomFactor, fromPage or toPage is empty. |
| 403 | A 403 (Forbidden) is returned, if the user is not authorized or the document quota is exceeded. |
| 404 | A 404 (Not Found) is returned, if a required query parameter is missing. |
| 405 | A 405 (Method Not Allowed) is returned, if the request uses another HTTP method than GET. The Allow header of the response names GET. |
| 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, or if imageFormat is empty. |

**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 template or the number of pages.

---

## Nearby

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