LiteParse
Local document parser built on PDF.js + Tesseract.js. Zero cloud dependencies.
Binary: lit (installed globally via npm)
Docs: https://developers.llamaindex.ai/liteparse/
Quick Reference
CODEBLOCK0
Output Formats
| Format | Use case |
|---|
| INLINECODE1 (default) | Plain text extraction, feeding into prompts |
| INLINECODE2 |
Structured output with bounding boxes, useful for layout-aware tasks |
OCR Behavior
- - OCR is on by default via Tesseract.js (downloads ~10MB English data on first run)
- First run will be slow; subsequent runs use cached data
- INLINECODE3 for pure text-layer PDFs (faster, no network needed)
- For multi-language: INLINECODE4
Supported File Types
Works natively: PDF
Requires LibreOffice (brew install --cask libreoffice): .docx, .doc, .xlsx, .xls, .pptx, .ppt, .odt, .csv
Requires ImageMagick (brew install imagemagick): .jpg, .png, .gif, .bmp, .tiff, .webp
Installation Notes
- - Installed via npm: INLINECODE7
- Brew formula exists (
brew tap run-llama/liteparse) but requires current macOS CLT — use npm as primary install path on this machine - Binary path: INLINECODE9
Workflow Tips
- - For VA forms, job description PDFs, military docs:
lit parse file.pdf -o /tmp/output.txt then read into context - For scanned PDFs (no text layer): OCR is required; complex layouts may degrade — consider LlamaParse cloud for critical docs
- For vision model workflows: use
lit screenshot to generate page images, then pass to image tool or similar - For batch jobs: use
lit batch-parse — it reuses the PDF engine across files for efficiency
Limitations
- - Complex tables, multi-column layouts, and scanned government forms may produce imperfect output
- LlamaParse (cloud) handles the hard cases: https://cloud.llamaindex.ai
- Max recommended DPI for screenshots: 300 (higher = slower, larger files)
Reference
See references/output-examples.md for sample JSON/text output structure.
LiteParse
基于PDF.js + Tesseract.js构建的本地文档解析器。零云端依赖。
二进制文件: lit(通过npm全局安装)
文档: https://developers.llamaindex.ai/liteparse/
快速参考
bash
将PDF解析为文本(标准输出)
lit parse document.pdf
解析到文件
lit parse document.pdf -o output.txt
解析为JSON(包含边界框)
lit parse document.pdf --format json -o output.json
仅解析特定页面
lit parse document.pdf --target-pages 1-5,10,15-20
不使用OCR(速度更快,仅限文本层PDF)
lit parse document.pdf --no-ocr
批量解析目录
lit batch-parse ./input-dir ./output-dir
截取页面截图(用于视觉模型输入)
lit screenshot document.pdf -o ./screenshots
lit screenshot document.pdf --target-pages 1,3,5 --dpi 300 -o ./screenshots
输出格式
| 格式 | 使用场景 |
|---|
| text(默认) | 纯文本提取,用于输入提示词 |
| json |
包含边界框的结构化输出,适用于布局感知任务 |
OCR行为
- - 默认通过Tesseract.js开启OCR(首次运行下载约10MB英文数据)
- 首次运行较慢;后续运行使用缓存数据
- --no-ocr用于纯文本层PDF(速度更快,无需网络)
- 多语言支持:--ocr-language fra+eng
支持的文件类型
原生支持:PDF
需要LibreOffice(brew install --cask libreoffice):.docx, .doc, .xlsx, .xls, .pptx, .ppt, .odt, .csv
需要ImageMagick(brew install imagemagick):.jpg, .png, .gif, .bmp, .tiff, .webp
安装说明
- - 通过npm安装:npm install -g @llamaindex/liteparse
- 存在Homebrew公式(brew tap run-llama/liteparse),但需要当前macOS命令行工具——本机建议使用npm作为主要安装路径
- 二进制文件路径:/opt/homebrew/bin/lit
工作流技巧
- - 对于VA表格、职位描述PDF、军事文档:使用lit parse file.pdf -o /tmp/output.txt然后读入上下文
- 对于扫描版PDF(无文本层):需要OCR;复杂布局可能降低效果——关键文档可考虑使用LlamaParse云端服务
- 对于视觉模型工作流:使用lit screenshot生成页面图像,然后传递给image工具或类似工具
- 对于批量任务:使用lit batch-parse——它会在文件间复用PDF引擎以提高效率
局限性
- - 复杂表格、多列布局和扫描版政府表单可能产生不完美的输出
- LlamaParse(云端)处理困难情况:https://cloud.llamaindex.ai
- 截图推荐最大DPI:300(更高值意味着更慢速度和更大文件)
参考
参见references/output-examples.md获取示例JSON/文本输出结构。