← Về thư mục
📄 / / profiles / r-and-d / raw_evidence / scientific-agent-skills / skills / liteparse / references / ocr_and_formats.md

OCR and Supported Input Formats

Built-in OCR (Tesseract)

lit parse document.pdf
lit parse document.pdf --ocr-language fra
lit parse document.pdf --no-ocr
parser = LiteParse(ocr_enabled=True, ocr_language="eng", num_workers=4)

Language codes

Use Tesseract codes (not ISO alone): eng, fra, deu, spa, chi_sim, etc. Map HTTP OCR language=en separately (see below).

Offline / air-gapped environments

Pre-download .traineddata files, then either:

export TESSDATA_PREFIX=/path/to/tessdata
lit parse document.pdf --ocr-language eng

or:

lit parse document.pdf --tessdata-path /path/to/tessdata

HTTP OCR servers (optional)

For higher accuracy or GPU-backed OCR, run a server implementing the LiteParse OCR API and point LiteParse at it:

lit parse document.pdf --ocr-server-url http://localhost:8080/ocr
parser = LiteParse(ocr_server_url="http://localhost:8080/ocr")

API contract (summary)

{
  "results": [
    {
      "text": "recognized text",
      "bbox": [x1, y1, x2, y2],
      "confidence": 0.95
    }
  ]
}

Reference server implementations (upstream repo)

You only need a server if you choose HTTP OCR; Tesseract is sufficient for many workflows.


Supported input formats

PDF (native)

.pdf — no conversion step.

Office documents (LibreOffice)

Requires LibreOffice installed and on PATH.

Type Extensions
Word .doc, .docx, .docm, .odt, .rtf, .pages
PowerPoint .ppt, .pptx, .pptm, .odp, .key
Spreadsheets .xls, .xlsx, .xlsm, .ods, .csv, .tsv, .numbers

Install LibreOffice:

# macOS
brew install --cask libreoffice

# Ubuntu/Debian
sudo apt-get install libreoffice

# Windows (Chocolatey)
choco install libreoffice-fresh

On Windows, add LibreOffice program directory to PATH (often C:\Program Files\LibreOffice\program).

Images (ImageMagick)

Requires ImageMagick.

Formats
.jpg, .jpeg, .png, .gif, .bmp, .tiff, .webp, .svg

Install ImageMagick:

# macOS
brew install imagemagick

# Ubuntu/Debian
sudo apt-get install imagemagick

# Windows
choco install imagemagick.app

Conversion pipeline

Office / image → (LibreOffice or ImageMagick) → PDF → PDFium extract → optional OCR → grid projection → text + JSON

If conversion fails, install the missing tool and retry. Plain-text-only paths cannot be screenshot-rendered.