Python bindings for LiteParse - fast, lightweight PDF and document parsing
Actively maintained. Last release 3 days ago, commits in 26 of the last 26 weeks. A safe choice.
pip install liteparseLiteParse Python
Python bindings for LiteParse — fast, lightweight PDF and document parsing with spatial text extraction.
Installation
pip install liteparse
This also installs the lit CLI command.
Quick Start
from liteparse import LiteParse
parser = LiteParse()
result = parser.parse("document.pdf")
print(result.text)
print(f"Source document pages: {result.total_pages}")
# Access structured data
for page in result.pages:
print(f"Page {page.page_num}: {len(page.text_items)} text items")
Markdown Output
LiteParse can render documents directly to Markdown including headings, tables, lists,
images, and links reconstructed from the spatial layout. Great for feeding LLMs
and RAG pipelines. The rendered Markdown is returned on result.text:
parser = LiteParse(
output_format="markdown", # "json" | "text" | "markdown"
image_mode="placeholder", # "placeholder" | "off" | "embed"
extract_links=True, # render [text](url) link syntax (default: True)
)
result = parser.parse("document.pdf")
print(result.text) # rendered Markdown
Reconstruction quality varies with document complexity.
Configuration
All options are passed to the constructor:
parser = LiteParse(
ocr_enabled=True, # Enable OCR (default: True)
ocr_language="eng", # Tesseract language code
ocr_server_url=None, # HTTP OCR server URL (optional)
ocr_backend=None, # "tesseract" | "ocria-nano" (default: OCRia-nano-1 once pulled, else tesseract)
tessdata_path=None, # Path to tessdata directory (optional)
max_pages=1000, # Max pages to parse
target_pages="1-5,10", # Specific pages (optional)
extract_screenshots=False, # Return parsed pages as PNG bytes
continue_on_page_error=False, # Skip broken pages and return page_errors
dpi=150, # Rendering DPI (default: 250 with OCRia-nano-1, else 150)
output_format="json", # "json" | "text" | "markdown"
image_mode="placeholder", # Markdown image handling: "placeholder" | "off" | "embed"
extract_images=True, # Extract image bytes + metadata (default: False)
image_output_dir="./images", # Write images and return name/path metadata (optional)
extract_links=True, # Render [text](url) links in markdown output
keep_headers_footers=False, # Keep running headers/footers in markdown output
keep_clipped_text=False, # Keep text hidden by clips (e.g. table-cell overflow)
extract_vector_graphics=False, # Opt-in shapes + merged H/V lines per page
extract_annotations=False, # Include page annotations in structured output
extract_form_fields=False, # Include AcroForm widget fields and values
extract_structure_tree=False, # Include tagged-PDF logical structure
preserve_very_small_text=False, # Keep tiny text
extract_text_metadata=False, # Opt in to MCID, font metrics, colors, char codes, and trailing_space_generated
password=None, # Password for protected documents
quiet=False, # Suppress progress output
num_workers=4, # Concurrent OCR workers
)