Command-line interface#
doctr-cli runs the complete OCR pipeline on images and PDFs from your terminal, and writes the result as JSON,
plain text, Markdown, AsciiDoc, HTML or hOCR. It is installed with the package.
doctr-cli --input_path invoice.pdf --output invoice.json
Common recipes#
doctr-cli --input_path scan.jpg --output scan.txt
doctr-cli --input_path report.pdf --detect_tables --output report.md
Every page of every input is appended to a single document:
doctr-cli --input_path page1.jpg page2.jpg annex.pdf --output dossier.json
doctr-cli --input_path skewed.pdf --straighten_pages --output skewed.txt
On a CUDA device of compute capability 8.0 or newer, the models run in bfloat16:
doctr-cli --input_path doc.pdf --device cuda:0 --output doc.xml
Requires the html extra:
doctr-cli --input_path https://www.example.com --output page.md
The format is inferred from the extension of --output (.json, .txt, .md, .adoc, .html, .xml) and
falls back to JSON. Use --format to set it explicitly.
Arguments#
Run doctr-cli --help for the full list with default values.
Input#
Argument |
Default |
Description |
|---|---|---|
|
— |
Required. One or more images, PDF files, or |
|
|
Password of encrypted PDF files |
|
|
PDF rendering scale (1 corresponds to 72 dpi) |
Models#
Argument |
Default |
Description |
|---|---|---|
|
|
Detection architecture |
|
|
Recognition architecture |
|
|
Layout architecture |
|
|
|
Processing#
Argument |
Default |
Description |
|---|---|---|
|
on |
Handle pages as straight (see Rotated documents) |
|
off |
Straighten rotated pages before reading them |
|
on |
Pad pages instead of stretching them |
|
on |
Pad on all sides |
|
|
Batch sizes of the detection and recognition models |
|
model |
Detection thresholds, between 0 and 1 |
|
model |
|
|
off |
Estimate the orientation of each page |
|
off |
Estimate the language of each page |
|
off |
Attach the layout regions to each page |
|
off |
Recognize tables (enables the layout model) |
|
none |
Layout classes to mask before OCR, e.g. |
|
off |
Export straight boxes with |
|
off |
With |
|
off |
Skip the page orientation classifier |
|
off |
Skip the crop orientation classifier |
Document assembly#
Argument |
Default |
Description |
|---|---|---|
|
on |
Group words into lines |
|
off |
Group lines into blocks |
|
|
Relative space that splits a line |
|
off |
Sort the content of each page in reading order |
Output#
Argument |
Default |
Description |
|---|---|---|
|
|
Output file |
|
from extension |
|
|
|
Reading direction: |
|
on |
Linearize JSON and hOCR exports in reading order |
|
on |
Escape markup characters (Markdown, AsciiDoc) |
|
on |
Include page headers, footers and footnotes |
|
|
Figures in Markdown, AsciiDoc and HTML: |
|
|
Directory of the figures with |
|
|
|
|
|
Title of the hOCR files |
|
|
Indentation of the JSON export |
|
off |
Only log errors |
|
Print the docTR version and exit |
Output files#
JSON contains the full structure: pages (dimensions, orientation, language, layout), blocks, lines and words with their confidence and geometry, and the tables with
--detect_tables.Text-like formats (
txt,md,adoc,html) are written to a single file.hOCR describes one page per file:
--output doc.xmlon a three-page document writesdoc_page_1.xml,doc_page_2.xmlanddoc_page_3.xml.