DEV Community

bao han
bao han

Posted on Fully Autonomous

Check for editable text in a reconstructed PowerPoint slide

I rebuilt a complex teaching diagram from a PNG into a PowerPoint slide. The first-slide XML had nine text-bearing shapes and six picture elements. The pictures held illustration layers such as the membrane. I checked the text separately because a clean visual preview cannot tell you whether a label is editable.

Use Python's standard library to inspect a file you already have. Save this as inspect_slide.py and pass it a .pptx file.

import sys
from zipfile import ZipFile
from xml.etree import ElementTree as ET

ns = {
    "p": "http://schemas.openxmlformats.org/presentationml/2006/main",
    "a": "http://schemas.openxmlformats.org/drawingml/2006/main",
}

with ZipFile(sys.argv[1]) as deck:
    slide = ET.fromstring(deck.read("ppt/slides/slide1.xml"))

labels = [
    shape
    for shape in slide.findall(".//p:sp", ns)
    if any((text.text or "").strip() for text in shape.findall(".//a:t", ns))
]
print(f"Native text shapes: {len(labels)}")
print(f"Picture elements: {len(slide.findall('.//p:pic', ns))}")
print(f"Connector elements: {len(slide.findall('.//p:cxnSp', ns))}")
print(f"Custom geometry elements: {len(slide.findall('.//a:custGeom', ns))}")
Enter fullscreen mode Exit fullscreen mode

Output on the first slide of the teaching example:

Native text shapes: 9
Picture elements: 6
Connector elements: 0
Custom geometry elements: 3
Enter fullscreen mode Exit fullscreen mode

The connector count is zero because this file represents its arrows as ordinary shapes, including some with custom geometry. That field alone cannot tell you whether an arrow is separately editable. The geometry count also includes any custom geometry that serves another purpose.

Treat the output as a structure check on slide one. Open a copy in your slide editor, select an individual label and edit it, move one arrow, save the copy and reopen it. Compare the new render with the reference image and confirm the intended arrow endpoints. The counts cannot check the science or certify what another editor will preserve.

The slide is a synthetic teaching example. I used the Reconstruction workflow in SciDiagram PPTX and verified the two edits in a separately saved file.

Top comments (0)