Skip to main content

Pure-Rust PowerPoint (.pptx / OOXML) structural parser with local image OCR, via PyO3.

Project description

pptspine

PyPI

A pure-Rust PowerPoint (.pptx) parser with Python bindings (PyO3 / maturin, abi3-py311). A .pptx file is OOXML — a zip archive of XML parts — and pptspine walks that XML directly to produce a structured, information-preserving model: slides, text frames (paragraphs + styled runs), tables (cells, merges, fills), pictures, and autoshapes. Embedded images can additionally be OCR'd locally, offline, and deterministically via the sibling ocrspine crate (PP-OCRv5 through tract-onnx — no cloud, no network).

Capabilities

Area Status
Slides + slide size parsed
Text frames: paragraphs, runs, text parsed
Run styling: font, size, bold, italic, solid-fill color parsed
Paragraph level + alignment parsed
Tables: rows, cells, cell text parsed
Table merges: gridSpan / rowSpan / hMerge / vMerge parsed
Cell solid-fill color parsed
Pictures: r:embed rel → media name + raw bytes parsed
Autoshapes: geometry name, fill, stroke, optional text parsed (best-effort)
Groups (p:grpSp): recursive parsed
Image OCR (embedded pictures → words + boxes) working (ocr_image)
Image-table geometry reconstruction from OCR boxes deferred (stub)

Parsing is tolerant: unknown elements are skipped, missing attributes become None, and malformed input yields a typed PptError rather than a panic.

Install

pip install pptspine

pptspine is on PyPI. OCR works out of the box: the PP-OCRv5 weights ship in the shared ocrspine-models data package — a runtime dependency pip pulls in automatically — so the wheel itself ships no models. To build from source instead, see below.

Build (from the package root)

uv venv .venv
VIRTUAL_ENV="$(pwd)/.venv" uv pip install maturin pytest
# Structural parsing needs no models. The OCR path resolves models from
# ../ocrspine/models by default (or set OCRSPINE_MODELS).
OCRSPINE_MODELS="$(cd ../ocrspine && pwd)/models" \
  VIRTUAL_ENV="$(pwd)/.venv" .venv/bin/maturin develop --release

Use from Python

import pptspine

pres = pptspine.open("deck.pptx")
print(pres.slide_count, pres.slide_size)   # e.g. 2 (9144000, 6858000)  # EMU

for slide in pres.slides():
    for shape in slide.shapes():           # list[dict], introspectable
        if shape["kind"] == "text":
            for para in shape["paragraphs"]:
                for run in para["runs"]:
                    print(run["text"], run["bold"], run["color"])
        elif shape["kind"] == "table":
            for row in shape["rows"]:
                print([cell["text"] for cell in row])
        elif shape["kind"] == "picture":
            print("image:", shape["media"])

# Run OCR on raw image bytes (PNG/JPEG), offline:
items = pptspine.ocr_image(open("scan.png", "rb").read())
print(" ".join(i["text"] for i in items))

Rust workspace

crates/
  ppt-core    domain model + geometry (EMU) + typed PptError. No IO/zip/XML.
  ppt-parse   OOXML reader: zip extract + quick-xml walk -> Presentation.
  ppt-ocr     image-OCR bridge over ocrspine (PaddleOcr).
  py-bindings PyO3 _core extension (the FFI chokepoint).

Deferred / follow-up

  • Image-table geometry reconstruction from OCR boxes (ppt_ocr::reconstruct_table_from_image, currently a typed Unsupported stub).
  • Richer color models (theme/scheme colors, gradients), hyperlinks, charts, SmartArt, notes/comments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pptspine-0.1.1.tar.gz (52.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pptspine-0.1.1-cp311-abi3-win_amd64.whl (6.1 MB view details)

Uploaded CPython 3.11+Windows x86-64

pptspine-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl (5.2 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.28+ ARM64

pptspine-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

pptspine-0.1.1-cp311-abi3-macosx_11_0_arm64.whl (4.9 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

pptspine-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl (6.5 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file pptspine-0.1.1.tar.gz.

File metadata

  • Download URL: pptspine-0.1.1.tar.gz
  • Upload date:
  • Size: 52.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pptspine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 617489a999c27bf4eb41c3e70af210bace1d8cb6c2b0dea32f58f5081afa9f2f
MD5 ac8f16b7205095e8b770b6eb23196a50
BLAKE2b-256 971af2956cb4767e678245f5246c92e22f501f0e4f1e331c35e61f8d1fc0d342

See more details on using hashes here.

File details

Details for the file pptspine-0.1.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: pptspine-0.1.1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.1 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pptspine-0.1.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3350f36ac0de06d96f590e86ef92d20321f0b8f99cc6fe2733c302e7d3a4852e
MD5 3aa44919a1a59a0e636c3049b8e0435c
BLAKE2b-256 621cde616eb3cfe443781a4e73974042352e2d0639e12037172407f8c821e8fa

See more details on using hashes here.

File details

Details for the file pptspine-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pptspine-0.1.1-cp311-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a4c89761a3ac2f1eef602ceea2f04c47610708cb05417fbeae93f6f78f4a4d56
MD5 a783a323a973a730a7222364c9e79d1f
BLAKE2b-256 fc2b7e360c5d01f8c324f424a8869d731e76a1f0aeb4539be93c5bff1279d286

See more details on using hashes here.

File details

Details for the file pptspine-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pptspine-0.1.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0ee12bf0819c89a511d33e50980b48df58c80f89688c2e67851d8767af401c67
MD5 e9c3837f7c8df9d75b4e7a7b2ad9e65c
BLAKE2b-256 b53a2a4b4ab0cda0f73aba354ac4965a55b355346fb47b9be82898774864bc8e

See more details on using hashes here.

File details

Details for the file pptspine-0.1.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pptspine-0.1.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18e77d2ee6bb3621ec9ff00322341034388d2127aa73e6462a302a9d81f0ed61
MD5 07cd3901bc728286fcb7a9236f74397b
BLAKE2b-256 4e3199a28932073d6d986eb5a5dfb140f7962d841daf9766a71d7995730105ef

See more details on using hashes here.

File details

Details for the file pptspine-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pptspine-0.1.1-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c01cf673cce01c7d2d10f085111bb175b02afe591fe81e5cd07b672d378c8f86
MD5 fe67ed149644eee95360a256ed172f62
BLAKE2b-256 e8b4b97bbaf6c2586f9fced6f761a21c7cf7a544486a33a4c9466217e366dcdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page