# Liteparse > Parseo local de documentos y PDF que devuelve texto espacial con bounding boxes: extrae texto, hace OCR de escaneos, genera JSON con layout para RAG y renderiza páginas a PNG. Todo local, sin API en la nube. Fuente: https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/liteparse Markdown: https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/liteparse.md Repositorio: https://github.com/K-Dense-AI/scientific-agent-skills Autor: K-Dense-AI Licencia: Apache-2.0 Actualizado: el mes pasado Coste de contexto: 104 tok instalada, 2.3k tok al activarse, 7.9k tok con todos los archivos del bundle Bundle: 7 archivos, 31 KB Permisos que pide: read write edit bash ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add K-Dense-AI/scientific-agent-skills --skill liteparse --agent claude-code # Cursor npx -y skills add K-Dense-AI/scientific-agent-skills --skill liteparse --agent cursor # Codex npx -y skills add K-Dense-AI/scientific-agent-skills --skill liteparse --agent codex # Gemini CLI npx -y skills add K-Dense-AI/scientific-agent-skills --skill liteparse --agent gemini # Windsurf npx -y skills add K-Dense-AI/scientific-agent-skills --skill liteparse --agent windsurf # Cline npx -y skills add K-Dense-AI/scientific-agent-skills --skill liteparse --agent cline ``` ## Qué hace - Extrae texto de PDF, DOCX, Office e imágenes en local con posiciones (bounding boxes) por token - Ejecuta OCR con Tesseract incluido, o un servidor OCR HTTP externo, sobre PDFs escaneados - Genera JSON con layout preservado para RAG, citas ancladas a regiones o lógica de tablas/figuras - Renderiza páginas a PNG para agentes multimodales que necesitan ver gráficos o texto manuscrito - Procesa carpetas completas en lote (batch) sin llamadas a la nube ## Cuándo usarla - Parsear PDFs u otros documentos localmente sin depender de una API en la nube - Necesitar texto espacial con bounding boxes para RAG con conciencia de layout - Hacer OCR sobre PDFs o imágenes escaneadas - Ingerir en lote carpetas de papers o bibliotecas de protocolos ## Cuándo no - Para convertir a Markdown para LLM (EPUB, audio, YouTube, HTML) — usa la skill markitdown - Para fusionar/dividir PDFs, formularios, marcas de agua o rotación — usa la skill pdf - Para tablas densas, manuscritos o pipelines cloud en producción — usa LlamaParse ## Qué la activa - "Extrae el texto de este PDF con las coordenadas de cada palabra" - "Haz OCR a estos PDFs escaneados en local" - "Convierte esta carpeta de papers a JSON con bounding boxes" - "Genera capturas PNG de estas páginas para el agente" ## Antes de instalar - Requiere Python 3.10+; LibreOffice para formatos Office e ImageMagick para imágenes son opcionales, y Tesseract para OCR viene incluido. - Necesita en el PATH: curl, python - makes network requests ## Archivos - SKILL.md — 9 KB - references/api_reference.md — 4 KB - references/choosing_a_parser.md — 3 KB - references/cli_reference.md — 3 KB - references/ocr_and_formats.md — 3 KB - references/output_formats.md — 4 KB - scripts/batch_parse_dir.py — 4 KB ## SKILL.md Reproducido tal cual desde K-Dense-AI/scientific-agent-skills bajo Apache-2.0. Esta sección es el documento original y está en inglés. # LiteParse — Local Document Parsing ## Overview LiteParse is a fast, open-source document parser (Rust core, Python/Node bindings) focused on **local, layout-aware text extraction** with bounding boxes. It does not produce Markdown and does not call cloud LLMs. Outputs are **plain text** (layout-preserved) or **structured JSON** with per-page `text_items` (position, font metadata, optional confidence). **Version note:** Examples target **liteparse 2.0.0** (PyPI, May 2026). The upstream V1 branch is legacy; this skill documents **V2 / main** only. For parser selection vs MarkItDown, the `pdf` skill, or LlamaParse, see `references/choosing_a_parser.md`. ## When to Use This Skill Use LiteParse when you need: - **Fast local parsing** of PDFs or converted Office/image files without cloud dependencies - **Spatial text** with bounding boxes for layout-aware RAG, citation grounding, or figure/table region logic - **OCR** on scanned PDFs or images (bundled Tesseract, or a user-run HTTP OCR server) - **Page screenshots** (PNG) for multimodal agents that must see charts, figures, or handwriting - **Batch ingestion** of literature folders, supplementary PDFs, or protocol libraries - **Page subsets** or **password-protected** PDFs ## When Not to Use | Task | Use instead | |------|-------------| | Markdown for LLM ingestion (EPUB, audio, YouTube, HTML) | `markitdown` skill | | Merge/split PDFs, forms, watermarks, rotation | `pdf` skill | | Dense tables, handwriting, production cloud pipelines | [LlamaParse](https://docs.cloud.llamaindex.ai/llamaparse/overview) (cloud; sign up separately) | ## Installation ```bash uv pip install "liteparse==2.0.0" ``` This installs the Python bindings and the **`lit`** CLI. Verify: ```bash lit --help python -c "import liteparse; print(liteparse.__version__)" ``` **Optional system tools** (for non-PDF inputs): - **LibreOffice** — Word, Excel, PowerPoint, OpenDocument, CSV/TSV - **ImageMagick** — PNG, JPEG, TIFF, WebP, SVG, etc. Install commands are in `references/ocr_and_formats.md`. **Node.js / TypeScript** (optional): `npm i @llamaindex/liteparse` — see `references/api_reference.md`. --- ## Quick Start ### Python ```python from liteparse import LiteParse parser = LiteParse(quiet=True) result = parser.parse("paper.pdf") print(result.text) for page in result.pages: print(f"Page {page.page_num}: {len(page.text_items)} items") ``` ### CLI ```bash # Layout-preserved text (default) lit parse paper.pdf # Structured JSON with bounding boxes lit parse paper.pdf --format json -o paper.json # Disable OCR on text-native PDFs (faster) lit parse paper.pdf --no-ocr ``` --- ## Core Workflows ### 1. Parse to layout-preserved text Best for quick full-document text or feeding chunkers that do not need coordinates. ```python parser = LiteParse(ocr_enabled=True, quiet=True) result = parser.parse("document.pdf") full_text = result.text ``` ```bash lit parse document.pdf -o output.txt ``` ### 2. Parse to structured JSON (bounding boxes) Use when building layout-aware RAG, highlighting source regions, or joining text with screenshots. ```python import json from liteparse import LiteParse parser = LiteParse(output_format="json", quiet=True) result = parser.parse("document.pdf") # Programmatic access for page in result.pages: for item in page.text_items: bbox = (item.x, item.y, item.width, item.height) # item.text, item.confidence, item.font_name, item.font_size ``` ```bash lit parse document.pdf --format json -o document.json ``` JSON field layout: `references/output_formats.md`. ### 3. Parse specific pages ```python parser = LiteParse(target_pages="1-5,10,15-20", quiet=True) result = parser.parse("long_paper.pdf") ``` ```bash lit parse long_paper.pdf --target-pages "1-5,10" ``` ### 4. Parse from bytes or stdin Useful for uploads, S3 downloads, or piping remote PDFs. ```python with open("document.pdf", "rb") as f: result = parser.parse(f.read()) ``` ```bash curl -sL https://example.com/report.pdf | lit parse - ``` ### 5. Page screenshots for multimodal agents Screenshots capture visual content that text extraction alone misses (figures, complex tables, handwriting). ```python from pathlib import Path parser = LiteParse(dpi=150, quiet=True) shots = parser.screenshot("document.pdf", page_numbers=[1, 2, 3]) out = Path("screenshots") out.mkdir(exist_ok=True) for s in shots: (out / f"page_{s.page_num}.png").write_bytes(s.image_bytes) ``` ```bash lit screenshot document.pdf --target-pages "1,3,5" -o ./screenshots lit screenshot document.pdf --dpi 300 -o ./screenshots ``` Combine **JSON parse + screenshots** when an agent needs both coordinates and pixels for the same pages. ### 6. Batch-parse a directory For large corpora, prefer the CLI (parallel OCR workers) or the bundled script. ```bash lit batch-parse ./papers ./parsed --format json --recursive lit batch-parse ./papers ./parsed --extension .pdf --no-ocr ``` ```bash python scripts/batch_parse_dir.py ./papers ./parsed --format json --recursive ``` See `scripts/batch_parse_dir.py` for a Python batch wrapper without network calls. ### 7. OCR configuration OCR is **on by default**. Tesseract is bundled; no extra install for basic English OCR. ```python parser = LiteParse( ocr_enabled=True, ocr_language="eng", # Tesseract codes: fra, deu, etc. num_workers=4, # parallel OCR (default: CPU cores - 1) dpi=150, # higher DPI → better OCR, slower ) ``` ```bash lit parse scan.pdf --ocr-language fra lit parse scan.pdf --no-ocr lit parse scan.pdf --ocr-server-url http://localhost:8080/ocr ``` **Offline / air-gapped:** set `TESSDATA_PREFIX` to a directory of `.traineddata` files, or pass `--tessdata-path`. Details: `references/ocr_and_formats.md`. ### 8. Encrypted PDFs ```python parser = LiteParse(password="secret", quiet=True) result = parser.parse("protected.pdf") ``` ```bash lit parse protected.pdf --password secret ``` ### 9. Search text items by phrase Merge adjacent items and return combined bounding boxes for a phrase (e.g. section titles). ```python from liteparse import search_items page = result.get_page(1) matches = search_items(page.text_items, "Materials and Methods", case_sensitive=False) ``` --- ## Multi-Format Inputs | Category | Extensions (examples) | Requirement | |----------|----------------------|-------------| | PDF | `.pdf` | Native | | Office | `.docx`, `.xlsx`, `.pptx`, `.doc`, `.odt`, … | LibreOffice | | Images | `.png`, `.jpg`, `.tiff`, `.webp`, `.svg`, … | ImageMagick | Files are converted to PDF internally, then parsed. If conversion tools are missing, parsing fails with an actionable error — install the dependency and retry. --- ## Performance Tips - **`--no-ocr`** on born-digital PDFs — largest speedup - **`target_pages`** — parse only methods/supplement sections - **`num_workers`** — scale OCR across CPU cores - **`max_pages`** — cap very large files (default 1000) - **`lit batch-parse`** — directory-scale jobs with `--recursive` and `--extension` - Lower **`dpi`** (e.g. 100) when OCR quality is already sufficient --- ## Reference Files | File | Read when | |------|-----------| | `references/choosing_a_parser.md` | Unsure whether to use LiteParse, MarkItDown, pdf, or LlamaParse | | `references/api_reference.md` | Python/TypeScript API, types, `search_items` | | `references/cli_reference.md` | Full `lit` command flags | | `references/output_formats.md` | JSON schema, bboxes, confidence scores | | `references/ocr_and_formats.md` | Tesseract, HTTP OCR, LibreOffice, ImageMagick | --- ## Troubleshooting | Issue | Fix | |-------|-----| | Office file fails | Install LibreOffice; ensure `soffice` is on PATH (Windows: add LibreOffice `program` dir) | | Image fails | Install ImageMagick; verify `convert` or `magick` works | | OCR poor quality | Increase `--dpi`; try `--ocr-language`; or HTTP OCR server | | OCR slow | `--no-ocr` if not needed; reduce pages; increase `num_workers` | | Air-gapped OCR | `export TESSDATA_PREFIX=/path/to/tessdata` or `--tessdata-path` | | `ParseError` on bytes | Ensure input is valid PDF bytes (Office bytes need a file path + conversion) | --- ## Resources - **GitHub**: https://github.com/run-llama/liteparse - **Docs**: https://developers.llamaindex.ai/liteparse/ - **PyPI**: https://pypi.org/project/liteparse/2.0.0/ - **npm**: https://www.npmjs.com/package/@llamaindex/liteparse - **OCR API spec**: https://github.com/run-llama/liteparse/blob/main/OCR_API_SPEC.md ## Dónde encaja - Categoría: [Documentos](https://skillsagentes.com/categorias/documentos.md) — Lee, escribe y transforma archivos PDF, DOCX, XLSX y PPTX. - Creador: [K-Dense-AI](https://skillsagentes.com/creators/k-dense-ai.md) — 163 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Citation Management](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/citation-management.md): Gestión integral de citas académicas: busca en OpenAlex, PubMed y Google Scholar, extrae metadatos precisos, valida citas y genera entradas BibTeX correctamente formateadas. - [Scientific Slides](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/scientific-slides.md): Crea decks de diapositivas y presentaciones para charlas de investigación: PowerPoint, presentaciones de conferencia, seminarios, defensas de tesis. Da estructura, plantillas, guía de tiempos y validación visual. - [Literature Review](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/literature-review.md): Realiza revisiones bibliográficas sistemáticas y completas usando varias bases académicas (PubMed, arXiv, bioRxiv, Semantic Scholar). Genera markdown y PDF con citas verificadas en varios estilos (APA, Nature, Vancouver). - [Infographics](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/infographics.md): Crea infografías profesionales con Nano Banana Pro AI y refinamiento iterativo inteligente. Usa Gemini 3.6 Flash para revisar la calidad e integra investigación con Perplexity Sonar. Soporta 10 tipos, 8 estilos y paletas para daltonismo. - [Latex Posters](https://skillsagentes.com/skills/k-dense-ai/scientific-agent-skills/latex-posters.md): Crea pósteres de investigación profesionales en LaTeX con beamerposter, tikzposter o baposter, para conferencias y comunicación científica: layout, colores, columnas múltiples e integración de figuras. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)