---
title: Documents and images
project: Total API
version: 2026
section: reference
language: en
license: 
url: https://totaljs.es/docs/total-api/2026/reference/documents-and-images/
updated: 2026-11-20T06:51:47.968Z
---

# Documents and images

> Print, convert and read files: PDF, OCR, invoices, license plates and captcha images.

Every service is a `POST` request with your token. See [Call Total API from Total.js](../../guides/call-from-totaljs/) and [Call Total API over HTTP](../../guides/call-over-http/).

## API

### POST https://api.totaljs.com/print/

Type: `rest`

Prints HTML or a web page to PDF, JPG or PNG.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `type` | `String` | yes |  | `pdf`, `jpg` or `png`. |
| `html` | `String` | no |  | The HTML to print. Send `html` or `url`. |
| `url` | `String` | no |  | The address of a web page to print. |
| `page` | `String` | no | `A4` | `A3`, `A4`, `A5` or `Letter`. |
| `width` | `Number` | no |  | PDF: the width of the page. Image: the width of the browser, in pixels. |
| `height` | `Number` | no |  | PDF: the height of the page. Image: the height of the browser, in pixels. |
| `dpi` | `Number` | no | `96` | PDF only. |
| `margin` | `String` | no | `0 0 0 0` | PDF only: `top right bottom left` in millimeters. |
| `viewport` | `String` | no |  | `xs` (phone), `sm` (tablet), `md` (medium screen) or `lg` (large screen). |
| `quality` | `Number` | no |  | The quality of an image. |
| `orientation` | `String` | no | `portrait` | `portrait` or `landscape`. |
| `grayscale` | `Boolean` | no |  | PDF only: a grayscale document. |
| `lowquality` | `Boolean` | no |  | PDF only: a smaller document of lower quality. |
| `zoom` | `Number` | no | `100` | The zoom in percent. |

Returns: `Binary` The file itself (binary data).

The HTML or the web page can have up to 512 kB.

Example: Total.js
```js
var file = await API('TAPI', 'print', { type: 'pdf', html: '<h1>Invoice 2026-001</h1>' }).promise();
```

Example: REST
```bash
curl -X POST https://api.totaljs.com/print/ \
	-H "Content-Type: application/json" \
	-H "X-Token: YOUR_TOKEN" \
	-d '{ "type": "pdf", "html": "<h1>Invoice 2026-001</h1>" }' \
	-o invoice.pdf
```

### POST https://api.totaljs.com/convert/

Type: `rest`

Converts a file to PDF, JPG or PNG.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `to` | `String` | yes |  | `pdf`, `jpg` or `png`. |
| `data` | `String` | yes |  | The file as a data URI, for example `data:application/pdf;base64,JVBERi0x...` |

Returns: `Binary` The converted file (binary data).

Example: Total.js
```js
var image = await API('TAPI', 'convert', { to: 'jpg', data: 'data:application/pdf;base64,JVBERi0x...' }).promise();
```

Example: REST
```bash
curl -X POST https://api.totaljs.com/convert/ \
	-H "Content-Type: application/json" \
	-H "X-Token: YOUR_TOKEN" \
	-d '{ "to": "jpg", "data": "data:application/pdf;base64,JVBERi0x..." }' \
	-o page.jpg
```

### POST https://api.totaljs.com/ocr/

Type: `rest`

Reads the text of a JPG, PNG or PDF file.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `data` | `String` | yes |  | The file as a data URI: JPG, PNG or PDF. |
| `language` | `String` | no | `eng` | The language of the text in an image, for example `eng` or `slk+eng` for two languages. PDF files ignore it. |

Returns: `Object` An object with the text in `text`.

Images are read with the Tesseract 5 engine, and the text keeps the layout of the image. The text of a PDF file is read from the file itself. The file can have up to 5 MB.

The codes of the languages are in the [list of Tesseract languages](https://tesseract-ocr.github.io/tessdoc/Data-Files-in-different-versions.html).

Example: Total.js
```js
var response = await API('TAPI', 'ocr', { data: 'data:image/png;base64,iVBORw0KGgo...', language: 'eng' }).promise();
console.log(response.text);
```

Example: REST
```bash
curl -X POST https://api.totaljs.com/ocr/ \
	-H "Content-Type: application/json" \
	-H "X-Token: YOUR_TOKEN" \
	-d '{ "data": "data:image/png;base64,iVBORw0KGgo...", "language": "eng" }'
```

Example: Response
```json
{ "text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit..." }
```

### POST https://api.totaljs.com/invoiceparser/

Type: `rest`

Reads the data of an invoice from a PDF, JPG or PNG file.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `data` | `String` | yes |  | The invoice as a data URI: PDF, JPG or PNG. |

Returns: `Object` The supplier, the customer and the numbers of the invoice.

Example: Total.js
```js
var invoice = await API('TAPI', 'invoiceparser', { data: 'data:application/pdf;base64,JVBERi0x...' }).promise();
```

Example: REST
```bash
curl -X POST https://api.totaljs.com/invoiceparser/ \
	-H "Content-Type: application/json" \
	-H "X-Token: YOUR_TOKEN" \
	-d '{ "data": "data:application/pdf;base64,JVBERi0x..." }'
```

Example: Response
```json
{
	"supplier": {
		"name": "Example Supplies Ltd.",
		"address": "Main Street 1, 10000 Example City",
		"vatid": "CZ00000000"
	},
	"customer": {
		"name": "Demo Company Ltd.",
		"address": "Demo Street 2, 20000 Demo City",
		"vatid": "SK0000000000"
	},
	"date": "2026-07-17",
	"number": "2026-0042",
	"amount": 120.5,
	"total": 145.81,
	"currency": "EUR",
	"language": null,
	"tax": 25.31
}
```

### POST https://api.totaljs.com/platenumber/

Type: `rest`

Reads a license plate from a JPG or PNG picture.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `data` | `String` | yes |  | The picture as a data URI: JPG or PNG. |
| `code` | `String` | no | `eu` | The kind of plates: `eu` or `us`. |

Returns: `Array` An array of the plates found, each with its confidence in percent.

Example: Total.js
```js
var plates = await API('TAPI', 'platenumber', { data: 'data:image/jpeg;base64,/9j/4AAQSkZJRg...' }).promise();
```

Example: REST
```bash
curl -X POST https://api.totaljs.com/platenumber/ \
	-H "Content-Type: application/json" \
	-H "X-Token: YOUR_TOKEN" \
	-d '{ "data": "data:image/jpeg;base64,/9j/4AAQSkZJRg..." }'
```

Example: Response
```json
[
	{ "value": "BB197FJ", "confidence": 87.434 }
]
```

### POST https://api.totaljs.com/captcha/

Type: `rest`

Draws a captcha image with the text that you send.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `value` | `String` | yes |  | The text of the image. |
| `width` | `Number` | no | `200` | The width in pixels. |
| `height` | `Number` | no | `80` | The height in pixels. |
| `dark` | `Boolean` | no | `false` | A dark image. |

Returns: `String` A JPEG image as a data URI.

Keep the text of the captcha on your server and compare it with what the user types.

Example: Total.js
```js
var image = await API('TAPI', 'captcha', { value: '123456' }).promise();
```

Example: REST
```bash
curl -X POST https://api.totaljs.com/captcha/ \
	-H "Content-Type: application/json" \
	-H "X-Token: YOUR_TOKEN" \
	-d '{ "value": "123456" }'
```

Example: Response
```text
data:image/jpeg;base64,/9j/4AAQSkZ...
```
