Installation
Requirements
- Python 3.10 or later
- pip 22+ (run
pip install --upgrade pipif unsure)
Base install
pip install docslicerThis covers PDF, DOCX, and PPTX parsing out of the box. No system dependencies required.
DocSlicer's own wheel is small — the bulk of the install comes from its dependencies:
| Package | Download (wheel) | Installed (on disk) | Notes |
|---|---|---|---|
docslicer | ~0.6 MB | ~4 MB | The library itself |
pandas | ~9.5 MB | ~66 MB | DataFrames flow through every pipeline step |
numpy | ~5.1 MB | ~31 MB | Coordinate math and chunk partitioning |
lxml | ~8.2 MB | ~19 MB | XML tree parser for DOCX and PPTX |
pypdfium2 | ~3.5 MB | ~8 MB | PDF text, images, shapes, links, and metadata extraction |
pikepdf | ~4.5 MB | ~13 MB | PDF parsing, decryption, and page-level recovery |
Pillow | ~4.8 MB | ~15 MB | Image handling; pulled in by pikepdf |
langdetect | ~1.0 MB | ~2 MB | Detects the language of extracted text |
pyyaml | ~0.2 MB | ~1 MB | YAML config parsing |
beautifulsoup4 | ~0.1 MB | ~1 MB | HTML parsing and static-page fallback |
httpx | ~0.1 MB | ~1 MB | HTTP fallback when Playwright unavailable |
| Total | ~38 MB | ~161 MB |
Measured on macOS arm64. The lxml wheel is larger on macOS because it ships a universal2 (arm64 + x86_64) binary; Linux builds are ~4 MB downloaded / ~8 MB installed.
Optional extras
| Extra | Package | Download | Installed (on disk) | Notes |
|---|---|---|---|---|
| html | playwright | ~4 MB | ~15 MB | Browser automation driver |
| html | playwright install chromium | ~150 MB | ~150 MB | Browser binary; not a pip package |
| llm | tiktoken | ~1 MB | ~3 MB | Exact token counts (cl100k_base); chars/4 fallback |
| ocr | tesserocr | ~3.8 MB | ~9.5 MB | Direct libtesseract bindings (bundled in the wheel), plus cysignals |
| ocr | brew install tesseract | ~20 MB | ~35 MB | Tesseract engine + language models; not a pip package |
| ocr | opencv-python | ~48 MB | ~119 MB | Image pre-processing before OCR |
| ocr | Pillow | — | — | Already installed with the base install (via pikepdf) |
| crypto | msoffcrypto-tool | ~4 MB | ~14 MB | Password-protected DOCX/PPTX; pulls in cryptography |
| parquet | pyarrow | ~25 MB | ~90 MB | Parquet read/write for chunk export |
| Total (all extras) | ~256 MB | ~436 MB |
HTML parsing
To parse URLs or JS-rendered pages, install the html extra:
pip install 'docslicer[html]'Then install the Chromium browser that Playwright will drive:
playwright install chromiumOnly Chromium is needed — DocSlicer does not use Firefox or WebKit.
Playwright is strongly recommended. DocSlicer will not crash without it — plain HTML fetching via httpx still works — but output quality degrades significantly. HTML structure detection relies on styling cues (bold, italic, underline, font size, color, ...) to distinguish headings from paragraphs and build an accurate document hierarchy. Static HTML pages carry almost none of this information. Skip Playwright only if you know your target pages are well-structured semantic HTML.
Token counting
The llm extra adds tiktoken for accurate token-count estimates on chunks:
pip install 'docslicer[llm]'OCR
The ocr extra enables text extraction from scanned PDFs via Tesseract:
pip install 'docslicer[ocr]'DocSlicer binds libtesseract directly through tesserocr. The tesserocr wheel bundles the library itself but not the language models, so the Tesseract engine still has to be installed on your system — DocSlicer auto-detects the path:
# macOS
brew install tesseract
# Debian / Ubuntu
apt install tesseract-ocrIf pip has to build tesserocr from source (no wheel for your platform), install the development libraries first:
# macOS
brew install tesseract leptonica
# Debian / Ubuntu
apt install tesseract-ocr libtesseract-dev libleptonica-dev pkg-configOCR is a fallback, not a primary use case. DocSlicer is built for native PDFs — documents with real embedded text and font data — and excels at extracting accurate structure from them. OCR works by rendering pages to images and reading pixels, which loses the precise character coordinates, font metrics, and styling cues that drive DocSlicer's hierarchy detection. If your PDFs are natively digital, skip this extra entirely.
Password-protected Office files
The crypto extra adds msoffcrypto-tool, which decrypts password-protected .docx and .pptx files before parsing:
pip install 'docslicer[crypto]'Pass the password with the password parameter — see parse_document. Encrypted PDFs are handled by pikepdf in the base install and do not need this extra.
Parquet export
pip install 'docslicer[parquet]'Everything at once
pip install 'docslicer[html,llm,ocr,crypto,parquet]'
playwright install chromiumPlaywright setup
Playwright requires a one-time browser download. The playwright install chromium command stores the browser in a local cache (~/.cache/ms-playwright on Linux/macOS).
CI environments — add the install step before your test run:
- run: pip install 'docslicer[html]'
- run: playwright install chromiumDocker — install the system dependencies Playwright needs:
playwright install-deps chromium
playwright install chromiumVersion pinning
Pin the exact version in requirements.txt:
docslicer==0.2.0
Or with extras:
docslicer[html]==0.2.0
In pyproject.toml:
[project]
dependencies = [
"docslicer==0.2.0",
]To check the latest version:
pip index versions docslicerUpgrading
pip install --upgrade docslicerAfter upgrading, re-run playwright install chromium if you use the html extra — Playwright occasionally requires a newer browser binary.
Next steps
- Quickstart — parse your first document in 2 minutes
- Format parsers — full parameter reference for all parsers