Skip to main content

LiteParse 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
)

When extract_images=True, image extraction is enabled. image_output_dir requires that explicit opt-in and writes the extracted bytes to disk. Each result.images entry includes its page bbox, intrinsic pixel dimensions, rotation, format, name, and path. Valid source JPEGs are preserved, exact duplicates reuse one file, and JSON CLI output contains metadata only (no base64 image data). image_mode controls Markdown presentation only and does not imply extraction. With extract_images=False, lightweight Markdown placement refs are still collected and result.images stays empty.

When extract_annotations is enabled, each parsed page has an annotations list containing the subtype, contents, author/title, PDF date strings, viewport-space rectangle and quadpoint rectangles, and URI for external link annotations. It is independent of extract_links, which controls Markdown link rendering. The field is None when extraction is disabled.

When extract_structure_tree=True, each page has a structure_tree containing all tagged-PDF roots and recursive elements with type, ID, actual/alternate text, title, typed attributes, MCIDs, children, and referenced link annotations. Untagged pages have an empty roots list; the field is None when disabled.

Every result also carries creator/producer from the PDF /Info dictionary. With extract_document_metadata=True, result.doc_meta adds a provenance object with dates, PDF version/security, signature state, incremental-save markers, trailer ID comparison, the catalog's XMP packet (capped at 64 KiB; skipped for sources over 16 MiB), and source size. It is off by default because it streams the whole source file, and it is None for inputs converted from a non-PDF format. These document fields are API-only and do not alter default CLI JSON.

OCR with OCRia-nano-1

OCRia-nano-1 is LiteParse's own OCR and table model package (8.1M parameters, CPU only): a line detector, a script router, four recognizers and LayoutNet, a learned table and layout model. It is opt-in: pull it once, after which it is the default OCR backend.

from liteparse import LiteParse, models

models.pull("ocria-nano")                  # once: models + ONNX Runtime (60-75 MB); prints the licence notice
parser = LiteParse(output_format="markdown")
result = parser.parse("scan.pdf")          # OCR + tables with OCRia-nano-1

LiteParse(ocr_backend="tesseract")         # Tesseract instead, for this parser
models.list()                              # installed packages
models.rm("ocria-nano")                    # remove

The CLI has the same commands (lit models pull|list|rm). With OCRia-nano-1, pages render at 250 dpi (Tesseract: 150) unless dpi is set, and ocr_language is ignored (it detects each line's script). The model weights are licensed separately from LiteParse (see the LICENSE installed with them).

See the OCRia-nano-1 guide and the model card.

Parsing from Bytes

Pass raw PDF bytes directly — useful for web uploads or downloaded files:

with open("document.pdf", "rb") as f:
    result = parser.parse(f.read())
print(result.text)

Worker Pool and Hard Timeouts

PDFium is not thread-safe, so in-process parses serialize on a process-global lock. For high-throughput services, or cases where you need to enforce a timeout, run parses in a pool of persistent worker processes instead:

from liteparse import LiteParse, ParseTimeoutError

parser = LiteParse(pool_size=4, parse_timeout=15)
parser.warm_up()  # optional: pre-initialize workers (~60ms total)

try:
    result = parser.parse("document.pdf")
except ParseTimeoutError as e:
    print(f"killed rogue document: {e.source} (deadline {e.timeout}s)")

parser.close()  # or use `with LiteParse(...) as parser:`

Screenshots

Generate PNG screenshots of document pages:

screenshots = parser.screenshot("document.pdf", page_numbers=[1, 2, 3])
for s in screenshots:
    print(f"Page {s.page_num}: {s.width}x{s.height}")
    with open(f"page_{s.page_num}.png", "wb") as f:
        f.write(s.image_bytes)

Document Complexity

Before committing to a full parse, check whether a document needs OCR or heavier processing. is_complex is a cheap, text-layer-only pass that returns one entry per page with a needs_ocr verdict and the signals behind it — useful for routing documents to different pipelines, rejecting ones you can't handle, or estimating cost.

parser = LiteParse()
pages = parser.is_complex("document.pdf")

if any(p.needs_ocr for p in pages):
    # Route to the OCR-enabled pipeline
    result = parser.parse("document.pdf")
else:
    # Cheap path — skip OCR entirely
    result = LiteParse(ocr_enabled=False).parse("document.pdf")

# Inspect why specific pages were flagged
for page in pages:
    if page.needs_ocr:
        print(f"Page {page.page_number}: {', '.join(page.reasons)}")

reasons is one of "scanned", "no-text", "sparse-text", "embedded-images", "garbled", "vector-text", or "annotation-text". Raw bytes work here too.

Supported Formats

  • PDF (.pdf)
  • Microsoft Office (.docx, .xlsx, .pptx, etc.) — requires LibreOffice
  • OpenDocument (.odt, .ods, .odp) — requires LibreOffice
  • Images (.png, .jpg, .tiff, etc.)
  • And more!

CLI

The Python package includes the lit CLI:

lit parse document.pdf
lit parse document.pdf --format json -o output.json
lit parse document.pdf --format json --extract-annotations
lit parse document.pdf --format json --extract-form-fields
lit screenshot document.pdf -o ./screenshots
lit batch-parse ./input ./output
lit is-complex document.pdf

Metadata

Release files for liteparse 2.21.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for liteparse 2.21.4
File Size Uploaded Provenance Actions
liteparse-2.21.4.tar.gz 902.6 kB With provenance Details for liteparse-2.21.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for liteparse 2.21.4
File Actions
liteparse-2.21.4-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details for liteparse-2.21.4-cp310-abi3-win_arm64.whl
liteparse-2.21.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for liteparse-2.21.4-cp310-abi3-win_amd64.whl
liteparse-2.21.4-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details for liteparse-2.21.4-cp310-abi3-musllinux_1_2_x86_64.whl
liteparse-2.21.4-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for liteparse-2.21.4-cp310-abi3-manylinux_2_28_x86_64.whl
liteparse-2.21.4-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for liteparse-2.21.4-cp310-abi3-manylinux_2_28_aarch64.whl
liteparse-2.21.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for liteparse-2.21.4-cp310-abi3-macosx_11_0_arm64.whl
liteparse-2.21.4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for liteparse-2.21.4-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 96.1 MB

Release files / liteparse-2.21.4.tar.gz

Download URL liteparse-2.21.4.tar.gz
Size 902.6 kB
Tags Source
SHA-256 checksum
How to use checksums
21622b29d187855fcde9e3bcb742c23a8c4e4e64d65700f40d6ca2ab0f23da48
BLAKE2b-256 checksum
How to use checksums
1bc48e806fb187f12716ed67d7b94c97c5e4832cc753773a8443e378406221aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-win_arm64.whl

Download URL liteparse-2.21.4-cp310-abi3-win_arm64.whl
Size 11.7 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
5e4b40ab4e24ed1354666edcc0398492c6467bbbd31965d40ce0510782a58d13
BLAKE2b-256 checksum
How to use checksums
3c19cfbb5dd9bb0fd3b7bfc2e25b0ac0e8c03641005ef8b3ca5fc11c8f11dce3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-win_amd64.whl

Download URL liteparse-2.21.4-cp310-abi3-win_amd64.whl
Size 12.4 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d1fa4b8dfdcdaeb61cd23771b7e55ea7271e98e23edf606a8add9b7b4d306a6b
BLAKE2b-256 checksum
How to use checksums
82856ddac7e3b6659fc94f8792a59dd4c26f31220ab87895e10c7a8f9d3a9534
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL liteparse-2.21.4-cp310-abi3-musllinux_1_2_x86_64.whl
Size 17.5 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
a0806dd717986933616dec6c12a2a78dec4dc8bd097fe687398ca9c1b55016cb
BLAKE2b-256 checksum
How to use checksums
f7c5c10aa28d33f883da14607787d9e1e711a6b9d27ba5625d66bd24385365b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL liteparse-2.21.4-cp310-abi3-manylinux_2_28_x86_64.whl
Size 14.4 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
23671d8f9daf1feaf97f85a32c79f4dc81baa77526a210f80318b20228bb3fc0
BLAKE2b-256 checksum
How to use checksums
afd9d7279e5bbcc864ab60c25b6f2bf4f7bbd31a4e0082ccca207bf32eb1273f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL liteparse-2.21.4-cp310-abi3-manylinux_2_28_aarch64.whl
Size 14.0 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
c4a5947c6cdfe76847822cebf528e4b5c77964367849491b68ef9e2bc4958a8d
BLAKE2b-256 checksum
How to use checksums
ebede7e856a5124d31565ce7e059005e34b2140b3cf903c7e0523df91d9d9c94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL liteparse-2.21.4-cp310-abi3-macosx_11_0_arm64.whl
Size 12.3 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
7b8545c7f2537c03e583825a0200728b706f4b7cc8905e210a025bf904534d21
BLAKE2b-256 checksum
How to use checksums
20d06e968804600d41d0b57ab8deacaed5d9db358c331b16dc6a15d00b4910b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / liteparse-2.21.4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL liteparse-2.21.4-cp310-abi3-macosx_10_12_x86_64.whl
Size 13.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b192b8c520c745c7cf6c460337727d550ae466840f817eb3beed7e3ac6fda6fc
BLAKE2b-256 checksum
How to use checksums
d14fe17f0614d7bf33e201bf586cd728f6c40095a3b3a24e8812c9f87f993f0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for liteparse 2.21.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for liteparse-2.21.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.21.4 This release

8 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page