
Using OCR inside of Directus
Leverage TTA's OCR interface to seamlessly integrate text recognition for PDFs and images within Directus.

OCR result
After using an OCR option on a file, a popup with an image preview will appear.
This window can be dragged around your screen for convenience.
Using the OCR Result
The preview will display a highlighted area with the recognized text.
- You can click on the text to make a selection.
- After selecting, click on any input field to fill it with the selected text.
Multiple pages in a PDF
When using PDFs with multiple pages, you can navigate through the pages using the arrows at the bottom of the preview.These will only be visible when the PDF has more than one page.

Using OCR inside of Directus Flows
It supports the following response types:
- Text
- HOCR (HTML like structure)
- Blocks
Operation Settings

Inside of the operation you have the following options:
Option | Description |
---|---|
File ID | The ID of the file you want to process. |
Mode | Can be either 'text', 'hocr' or 'blocks'. |
Language | Pick a language for the OCR process. |
Output
The output of the operation depends on the mode you selected. The output will be a string with the text or a JSON object with the blocks or hocr data. You can open the extensions tab to see how the JSON object is structured.
Using OCR in your own Directus extension
const result = await globalThis.TTA.OCRBasedOnAsset(
fileID,
language, // for example eng for english
mode // can be text, horc or blocks
);
Output
The output of the operation depends on the mode you selected.
The output will be a string with the text or a JSON object with the blocks or hocr data.
Example of the blocks output
[{
'bbox': {
'x0': 34,
'y0': 48,
'x1': 563,
'y1': 717
},
'text': 'Invoice mycompany@example.com\nEi a\n\nDirectus shares 1 $100 $100\n...',
'confidence': 85,
'blocktype': 1,
'paragraphs': [
{
'bbox': { 'x0': 34, 'y0': 48, 'x1': 563, 'y1': 90 },
'text': 'Invoice mycompany@example.com\nEi a\n\n',
'confidence': 45,
'is_ltr': 1,
'lines': [ /* ... */ ]
}
]
}]