A fast, helpful, and open-source document parser
update READMEs
Logan Markewichee72208556b6
diff --git a/README.md b/README.mdindex 503d9cf..e1f1dad 100644--- a/README.md+++ b/README.md@@ -18,15 +18,15 @@> Looking for LiteParse V1? Follow this link to [the old code](https://github.com/run-llama/liteparse/tree/logan/liteparse-v1)-LiteParse is a standalone OSS PDF parsing tool focused exclusively on **fast and light** parsing. It provides high-quality spatial text parsing with bounding boxes, without proprietary LLM features or cloud dependencies. Everything runs locally on your machine.+LiteParse is a standalone OSS PDF parsing tool focused exclusively on **fast and light** parsing. It provides high-quality spatial text parsing with bounding boxes, without proprietary LLM features or cloud dependencies. Everything runs locally on your machine.**Hitting the limits of local parsing?**-For complex documents (dense tables, multi-column layouts, charts, handwritten text, or-scanned PDFs), you'll get significantly better results with [LlamaParse](https://developers.llamaindex.ai/python/cloud/llamaparse/?utm_source=github&utm_medium=liteparse),-our cloud-based document parser built for production document pipelines. LlamaParse handles the+For complex documents (dense tables, multi-column layouts, charts, handwritten text, or+scanned PDFs), you'll get significantly better results with [LlamaParse](https://developers.llamaindex.ai/python/cloud/llamaparse/?utm_source=github&utm_medium=liteparse),+our cloud-based document parser built for production document pipelines. LlamaParse handles thehard stuff so your models see clean, structured data and markdown.-> π [Sign up for LlamaParse free](https://cloud.llamaindex.ai?utm_source=github&utm_medium=liteparse)+> [Sign up for LlamaParse free](https://cloud.llamaindex.ai?utm_source=github&utm_medium=liteparse)## Overview@@ -42,21 +42,21 @@ hard stuff so your models see clean, structured data and markdown.- **Multi-platform**: Linux, macOS (Intel/ARM), Windows```mermaid-flowchart LR+flowchart LRsubgraph Input["Input Formats"]- direction TB- PDF["PDF"]- DOCX["DOCX"]+ direction TB+ PDF["PDF"]+ DOCX["DOCX"]XLSX["XLSX"]PPTX["PPTX"]IMG["Images"]end- subgraph Core["π¦ Rust Core"]+ subgraph Core["Rust Core"]direction TBCONV["Format Conversion\nLibreOffice / ImageMagick"]EXTRACT["Text Extraction\nPDFium C library"]- OCR["Selective OCR\nTesseract Β· HTTP Β· Custom"]+ OCR["Selective OCR\nTesseract / HTTP / Custom"]MERGE["OCR Merge\nNative text + OCR results"]PROJ["Grid Projection\nSpatial layout reconstruction"]CONV --> EXTRACT@@ -72,11 +72,11 @@ flowchart LRendsubgraph Bindings["Language Bindings"]- direction TB+ direction TBNAPI["Node.js / TypeScript\nnapi-rs"]PYO3["Python\nPyO3"]WASM["Browser / WASM\nwasm-bindgen"]- CLI["CLI\ncargo Β· npm Β· pip"]+ CLI["CLI\ncargo / npm / pip"]NAPI ~~~ PYO3 ~~~ WASM ~~~ CLIend@@ -114,77 +114,14 @@ flowchart LR## Installation-All versions (except WASM) ship with the same CLI and library API. Install the one that fits your environment:--<details>- <summary>Node.js / TypeScript</summary>--Install via npm to use the `lit` CLI or the library API:--```bash-npm i -g @llamaindex/liteparse # CLI (global)-npm i @llamaindex/liteparse # Library (project dependency)-```--Parse your first document right away:--```bash-lit parse document.pdf-```--Or use the library API in your Node.js or TypeScript project:+Install via your preferred package manager. All versions (except WASM) ship with the same `lit` CLI.-```typescript-import { LiteParse } from '@llamaindex/liteparse';--const parser = new LiteParse({ ocrEnabled: true });--const result = await parser.parse('document.pdf');-console.log(result.text);-```-</details>--<details>- <summary>Python</summary>--Install via pip to use the `lit` CLI or the library API:--```bash-pip install liteparse-```--Parse your first document right away:--```bash-lit parse document.pdf-```--Or use the library API in your Python project:--```python-from liteparse import LiteParse--parser = LiteParse(ocr_enabled=True)-result = parser.parse('document.pdf')-print(result.text)-```--</details>--<details>- <summary>Browser (WASM)</summary>--You can install a trimmed-down version of LiteParse that runs entirely in the browser, with no server or cloud dependencies.--```bash-npm install @llamaindex/liteparse-wasm-```--It supports PDF parsing and custom OCR engines implemented in JavaScript.--See the [WASM package README](packages/wasm/README.md) for usage details.--</details>+| Language | Install | Library Docs |+|----------|---------|--------------|+| **Node.js / TypeScript** | `npm i @llamaindex/liteparse` | [Node.js README](packages/node/README.md) |+| **Python** | `pip install liteparse` | [Python README](packages/python/README.md) |+| **Rust** | `cargo install liteparse` (CLI) / `cargo add liteparse` (lib) | [Rust README (crates.io)](crates/liteparse/README.md) |+| **Browser (WASM)** | `npm i @llamaindex/liteparse-wasm` | [WASM README](packages/wasm/README.md) |### Agent Skill@@ -198,7 +135,7 @@ Or copy-pasting the [`SKILL.md`](https://github.com/run-llama/llamaparse-agent-s## CLI Usage-The CLI is the same across all installations (`npm`, `pip`, or the Rust binary).+The CLI is the same across all installations (`npm`, `pip`, `cargo install`).### Parse Files@@ -301,39 +238,6 @@ Options:-h, --help Print help```-## Library Usage--### Buffer / Uint8Array Input--All APIs that accept file paths also accept raw bytes, so you can parse documents from any source (e.g. HTTP responses, in-memory buffers) without writing to disk first.--The WASM package only accepts `Uint8Array` input, while the Node.js and Python versions accept both file paths and bytes.--```typescript-import { LiteParse } from '@llamaindex/liteparse';--const parser = new LiteParse();--// From a file read-const pdfBytes = await readFile('document.pdf');-const result = await parser.parse(pdfBytes);--// From an HTTP response-const response = await fetch('https://example.com/document.pdf');-const buffer = Buffer.from(await response.arrayBuffer());-const result2 = await parser.parse(buffer);-```--#### Screenshots--```typescript-const screenshots = await parser.screenshot('document.pdf', [1, 2, 3]);-for (const s of screenshots) {- console.log(`Page ${s.pageNum}: ${s.width}x${s.height}`);- // s.imageBuffer contains PNG bytes-}-```-## OCR Setup### Default: Tesseractdiff --git a/crates/liteparse/Cargo.toml b/crates/liteparse/Cargo.tomlindex ec7aa3b..c2e0ce4 100644--- a/crates/liteparse/Cargo.toml+++ b/crates/liteparse/Cargo.toml@@ -5,6 +5,7 @@ edition.workspace = truelicense.workspace = truerepository.workspace = truedescription = "Fast, lightweight PDF and document parsing with spatial text extraction"+readme = "README.md"[lib]name = "liteparse"diff --git a/crates/liteparse/README.md b/crates/liteparse/README.mdnew file mode 100644index 0000000..a95fddd--- /dev/null+++ b/crates/liteparse/README.md@@ -0,0 +1,116 @@+# LiteParse++[](https://crates.io/crates/liteparse)+[](https://opensource.org/licenses/Apache-2.0)++Rust library and CLI for fast, lightweight PDF and document parsing with spatial text extraction. Runs entirely locally with zero cloud dependencies.++> LiteParse is also available for [Node.js/TypeScript](https://www.npmjs.com/package/@llamaindex/liteparse), [Python](https://pypi.org/project/liteparse/), and the [browser (WASM)](https://www.npmjs.com/package/@llamaindex/liteparse-wasm). See the [project README](https://github.com/run-llama/liteparse) for all options.++## Installation++Add to your `Cargo.toml`:++```toml+[dependencies]+liteparse = "2"+```++Or install the CLI:++```bash+cargo install liteparse+```++## Quick Start++```rust+use liteparse::{LiteParse, LiteParseConfig};++#[tokio::main]+async fn main() -> Result<(), Box<dyn std::error::Error>> {+ let parser = LiteParse::new(LiteParseConfig::default());+ let result = parser.parse("document.pdf").await?;++ println!("{}", result.text);++ for page in &result.pages {+ println!("Page {}: {} text items", page.page_num, page.text_items.len());+ }++ Ok(())+}+```++## Configuration++```rust+use liteparse::{LiteParse, LiteParseConfig, OutputFormat};++let config = LiteParseConfig {+ ocr_enabled: true, // Enable OCR (default: true)+ ocr_language: "eng".to_string(), // Tesseract language code+ ocr_server_url: None, // HTTP OCR server URL (optional)+ tessdata_path: None, // Path to tessdata directory (optional)+ max_pages: 1000, // Max pages to parse+ target_pages: Some("1-5,10".into()), // Specific pages (optional)+ dpi: 150.0, // Rendering DPI+ output_format: OutputFormat::Json, // Output format+ preserve_very_small_text: false, // Keep tiny text+ password: None, // Password for protected documents+ quiet: false, // Suppress progress output+ ..Default::default()+};++let parser = LiteParse::new(config);+```++## Parsing from Bytes++```rust+use liteparse::types::PdfInput;++let pdf_bytes: Vec<u8> = std::fs::read("document.pdf")?;+let result = parser.parse_input(PdfInput::Bytes(pdf_bytes)).await?;+println!("{}", result.text);+```++## Custom OCR Engine++Implement the `OcrEngine` trait to plug in your own OCR backend:++```rust+use liteparse::ocr::OcrEngine;+use std::sync::Arc;++let parser = LiteParse::new(LiteParseConfig::default())+ .with_ocr_engine(Arc::new(my_engine));+```++## Features++- **`tesseract`** (default) β Built-in Tesseract OCR via `tesseract-rs`. Disable with `default-features = false` if you don't need OCR or want to use an HTTP OCR server instead.++## Supported Formats++- PDF (`.pdf`)+- Microsoft Office (`.docx`, `.xlsx`, `.pptx`, etc.) β requires LibreOffice+- OpenDocument (`.odt`, `.ods`, `.odp`) β requires LibreOffice+- Images (`.png`, `.jpg`, `.tiff`, etc.) β requires ImageMagick++## CLI++The crate also builds the `lit` CLI binary:++```bash+lit parse document.pdf+lit parse document.pdf --format json -o output.json+lit screenshot document.pdf -o ./screenshots+lit batch-parse ./input ./output+```++See `lit --help` for all options.++## License++Apache-2.0