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

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)

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

Release files for liteparse 2.13.0

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

Built distributions (wheels)

Table of built distributions (wheels) for liteparse 2.13.0
File
liteparse-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64 Details
liteparse-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ ARM64 Details
liteparse-2.13.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
liteparse-2.13.0-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details
liteparse-2.13.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
liteparse-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64 Details
liteparse-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ ARM64 Details
liteparse-2.13.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
liteparse-2.13.0-cp311-cp311-macosx_10_12_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.12+ x86-64 Details
liteparse-2.13.0-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
liteparse-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ x86-64 Details
liteparse-2.13.0-cp310-cp310-manylinux_2_28_aarch64.whl CPython 3.10 CPython 3.10 Linux glibc 2.28+ ARM64 Details

Total release size: 154.7 MB

Release files / liteparse-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl

Download URL liteparse-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl
Size 13.8 MB
Tags CPython 3.12 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
19c5e6a7f5ffcf50831e74490af85c0fd09ee1b995e3f36c6db27303bd9bd636
BLAKE2b-256 checksum
How to use checksums
8b723d83fee5c1ecab63bbfad54124cf59bf11b21d36d5fdad9762fd5c55077e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl

Download URL liteparse-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl
Size 13.5 MB
Tags CPython 3.12 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
eaead122bcde54ba3ea15eb032558fb5ab5ebbd610ead33bcb7e59cae81a1aef
BLAKE2b-256 checksum
How to use checksums
3b04233e7b6689a93020a15bfc920d4eafdbff4c92608ae283c4bca3badef374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL liteparse-2.13.0-cp312-cp312-macosx_11_0_arm64.whl
Size 11.9 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6a7cd7ef5ff11dfa53913bac888653b537ff50892ae647e7b18536902d854e52
BLAKE2b-256 checksum
How to use checksums
71e0070aa94c63229508415f04b7d8a6500daa11b9ffa4dcef4ac875dbf67336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp312-cp312-macosx_10_12_x86_64.whl

Download URL liteparse-2.13.0-cp312-cp312-macosx_10_12_x86_64.whl
Size 12.6 MB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
dc577f637c3f4d1f8369f449979d0ce8ef95d54da1b4f1fb7f0597ca235edc94
BLAKE2b-256 checksum
How to use checksums
619186b1f301618406ab3167c4b19a8c4c2681431c7fc224de681559ee673a05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp311-cp311-win_amd64.whl

Download URL liteparse-2.13.0-cp311-cp311-win_amd64.whl
Size 12.0 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
0469f0ed41956909c8ef92a4ad56800219aa1ab82c205e91107a00f1b05ff9a9
BLAKE2b-256 checksum
How to use checksums
4334dcf3b3f72cdc741b1e943cc69758609ef93ae6aaf53be2e20a2004b0d67c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl

Download URL liteparse-2.13.0-cp311-cp311-manylinux_2_28_x86_64.whl
Size 13.8 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
1961df6569d46b0697e2ca696036f77e759a9848569b5954874ca09b2d381a24
BLAKE2b-256 checksum
How to use checksums
b95ec618e13b358062be927092cb0633faafe4d2d9f2cbbfcc293628c2ccffbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl

Download URL liteparse-2.13.0-cp311-cp311-manylinux_2_28_aarch64.whl
Size 13.5 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
f9709e41583eb571da4bd614e7ee1978e676ff7ba659345425915a1ddb9cff1a
BLAKE2b-256 checksum
How to use checksums
e4eff83db3984ce0cb0336581895b911c7eb2b63ceae73d5e206ae60f46b7234
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL liteparse-2.13.0-cp311-cp311-macosx_11_0_arm64.whl
Size 12.0 MB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
4fe8c84cdb8a85946a1f97c05c750a8f31b40ea4a6c9607e12abd3d2047547b3
BLAKE2b-256 checksum
How to use checksums
8af9315c37623b398df01e20ad877c79cb00bfffd652866ee10a0b4ae601a999
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp311-cp311-macosx_10_12_x86_64.whl

Download URL liteparse-2.13.0-cp311-cp311-macosx_10_12_x86_64.whl
Size 12.6 MB
Tags CPython 3.11 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e4a73dae3159346cce77953d1d6296be329a5d2f6bef5655877bd23c72098096
BLAKE2b-256 checksum
How to use checksums
3b28cd84f4a003483f87676c0129461c138c045ecb1d1165ee2f5aba60b399e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp310-cp310-win_amd64.whl

Download URL liteparse-2.13.0-cp310-cp310-win_amd64.whl
Size 12.0 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
d076ded5dc27795577a906d856adc8167e63f08af5d651ce814dee91e6f54f53
BLAKE2b-256 checksum
How to use checksums
55bf677e6b0d3790231caeb159d5693c0e03e2dcb75e357e6a3c7b8af20e9c97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl

Download URL liteparse-2.13.0-cp310-cp310-manylinux_2_28_x86_64.whl
Size 13.8 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
61d287ec0c7d5a3765faf6962bbb56673a47903511052d90d900040494f4a920
BLAKE2b-256 checksum
How to use checksums
8e4b70c822d44df98db008d997ec3313686c0775b620b346340c8a1dde4cc1ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / liteparse-2.13.0-cp310-cp310-manylinux_2_28_aarch64.whl

Download URL liteparse-2.13.0-cp310-cp310-manylinux_2_28_aarch64.whl
Size 13.5 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64
SHA-256 checksum
How to use checksums
d4c9e11b0f5dc64a429d93164fd27767ac781b6d8874c36ae7559b9019962e1e
BLAKE2b-256 checksum
How to use checksums
3b2939e78a5f6635135ccce348c35bf7f5a3dbc95c64187c776881e30c8ea6c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

2.14.6

8 release files

2.14.5

8 release files

2.14.2

8 release files

2.14.1

8 release files

2.14.0

8 release files

This release

2.13.0 This release

12 release files

2.9.0

36 release files

2.8.1

36 release files

2.8.0

36 release files

2.7.0

36 release files

2.6.0

36 release files

2.5.1

36 release files

2.4.0

36 release files

2.3.0

36 release files

2.2.1

36 release files

2.2.0

36 release files

2.1.1

36 release files

2.1.0

36 release files

2.0.8

32 release files

2.0.4

24 release files

2.0.3

24 release files

2.0.1

24 release files

2.0.0

24 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

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