Home

Installation


Requirements

  • Python 3.10 or later
  • pip 22+ (run pip install --upgrade pip if unsure)

Base install

pip install docslicer

This 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:

PackageDownload (wheel)Installed (on disk)Notes
docslicer~0.6 MB~4 MBThe library itself
pandas~9.5 MB~66 MBDataFrames flow through every pipeline step
numpy~5.1 MB~31 MBCoordinate math and chunk partitioning
lxml~8.2 MB~19 MBXML tree parser for DOCX and PPTX
pypdfium2~3.5 MB~8 MBPDF text, images, shapes, links, and metadata extraction
pikepdf~4.5 MB~13 MBPDF parsing, decryption, and page-level recovery
Pillow~4.8 MB~15 MBImage handling; pulled in by pikepdf
langdetect~1.0 MB~2 MBDetects the language of extracted text
pyyaml~0.2 MB~1 MBYAML config parsing
beautifulsoup4~0.1 MB~1 MBHTML parsing and static-page fallback
httpx~0.1 MB~1 MBHTTP 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

ExtraPackageDownloadInstalled (on disk)Notes
htmlplaywright~4 MB~15 MBBrowser automation driver
htmlplaywright install chromium~150 MB~150 MBBrowser binary; not a pip package
llmtiktoken~1 MB~3 MBExact token counts (cl100k_base); chars/4 fallback
ocrtesserocr~3.8 MB~9.5 MBDirect libtesseract bindings (bundled in the wheel), plus cysignals
ocrbrew install tesseract~20 MB~35 MBTesseract engine + language models; not a pip package
ocropencv-python~48 MB~119 MBImage pre-processing before OCR
ocrPillowAlready installed with the base install (via pikepdf)
cryptomsoffcrypto-tool~4 MB~14 MBPassword-protected DOCX/PPTX; pulls in cryptography
parquetpyarrow~25 MB~90 MBParquet 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 chromium

Only 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-ocr

If 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-config

OCR 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 chromium

Playwright 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 chromium

Docker — install the system dependencies Playwright needs:

playwright install-deps chromium
playwright install chromium

Version 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 docslicer

Upgrading

pip install --upgrade docslicer

After upgrading, re-run playwright install chromium if you use the html extra — Playwright occasionally requires a newer browser binary.


Next steps