Parsing
Open a .pptx deck and walk its slides, shapes, tables, pictures, and speaker notes, or convert it to text / Markdown, with optional local OCR.
pptspine parses a .pptx into an introspectable model. Open a deck, then walk
its slides and shapes, or convert the whole thing to text or Markdown.
Opening a deck
import pptspine
pres = pptspine.open("deck.pptx") # from a path
pres = pptspine.open_bytes(raw_bytes) # from in-memory bytes
len(pres) # slide count (also pres.slide_count)
pres.slide_size_points # (width, height) in pointsopen and open_bytes both return a Presentation handle. A malformed file
raises a typed pptspine.PptError subtype rather than panicking.
Slides and shapes
for slide in pres.slides():
print(slide.index, slide.layout_name, slide.master_name)
print(slide.text) # all text on the slide
print(slide.notes) # speaker notes, or NoneEach slide's shapes are returned as introspectable dict objects tagged by
kind. A text shape exposes its paragraphs and styled runs; a table shape its
rows and cells; a picture its media name:
for shape in slide.shapes():
kind = shape["kind"] # "text" | "table" | "picture" | ...
if kind == "text":
for para in shape["paragraphs"]:
for run in para["runs"]:
print(run["text"], run["bold"], run["color"])
elif kind == "table":
for row in shape["rows"]:
print([cell["text"] for cell in row])
elif kind == "picture":
data = pres.image_bytes(shape["media"]) # raw image bytes, or NoneText and Markdown
text = pres.to_text() # plain text in reading order
md = pres.to_markdown() # GitHub-Flavored MarkdownLocal OCR
Embedded images can be OCR'd offline — no network, deterministic — via the
module-level ocr_image:
data = pres.image_bytes(name)
if data is not None:
for item in pptspine.ocr_image(data):
print(item["text"], item["confidence"], item["bbox"])Errors
Every failure surfaces as a typed exception under pptspine.PptError:
| Exception | Raised when |
|---|---|
PptError | Base class for every pptspine error. |
PptZipError | The .pptx zip container is unreadable. |
PptXmlError | An XML part is malformed. |
PptUnsupportedError | A structure isn't supported. |
PptOcrError | OCR failed. |
See PDF export to render a parsed deck to PDF.
PDF export
Render a .pptx deck to PDF with Presentation.to_pdf and save_pdf — one page per slide, font maps, degradation warnings, and the rendering features covered.
docspine
A pure-Rust Word (.docx) parser with a first-class table model and Python bindings — structural parsing plus faithful .docx → PDF export. Apache-2.0, on PyPI.