docling icon indicating copy to clipboard operation
docling copied to clipboard

PowerPoint backend drops pictures inserted into a picture placeholder (#665 still reproduces)

Open dlaszlo opened this issue 1 month ago • 2 comments

Bug

A picture inserted through a layout's picture placeholder (the "Click icon to add picture" box, e.g. in the default "Picture with Caption" layout) is not in document.pictures. No warning is emitted. This is what #665 reported; it was closed in May 2025 as already addressed, but it still reproduces on 2.131.0, and the check that causes it is unchanged on main.

The slide XML stores such a picture as an ordinary <p:pic> that carries a <p:ph type="pic"> reference. python-pptx returns it as a PlaceholderPicture, whose shape_type is MSO_SHAPE_TYPE.PLACEHOLDER, not PICTURE.

Steps to reproduce

from io import BytesIO

from PIL import Image
from pptx import Presentation
from docling.document_converter import DocumentConverter

png = BytesIO()
Image.new("RGB", (200, 100), (200, 30, 30)).save(png, format="PNG")

deck = Presentation()
slide = deck.slides.add_slide(deck.slide_layouts[8])  # "Picture with Caption"
placeholder = next(p for p in slide.placeholders if p.placeholder_format.type == 18)  # PP_PLACEHOLDER.PICTURE
picture = placeholder.insert_picture(png)
print(type(picture).__name__, picture.shape_type)  # PlaceholderPicture PLACEHOLDER (14)
deck.save("placeholder.pptx")

doc = DocumentConverter().convert("placeholder.pptx").document
print(len(doc.pictures))  # 0

Cause

docling/backend/mspowerpoint_backend.py, handle_shapes (line 1501 on main):

if _safe_shape_type(shape) == MSO_SHAPE_TYPE.PICTURE:
    # Handle Pictures
    self._handle_pictures(shape, parent_slide, slide_ind, doc, slide_size)

A PlaceholderPicture never passes this test, so _handle_pictures is not called for it.

Expected

The picture is in document.pictures, like any other <p:pic> on the slide. Testing the class instead of shape_type would cover both: PlaceholderPicture subclasses pptx.shapes.picture.Picture, so isinstance(shape, Picture) is true for an ordinary picture and for a placeholder picture alike:

from pptx.shapes.picture import Picture

if isinstance(shape, Picture):
    # Handle Pictures, including those inserted into a picture placeholder
    self._handle_pictures(shape, parent_slide, slide_ind, doc, slide_size)

Environment

  • docling 2.131.0, docling-core 2.99.0 (the check above is unchanged on main, v2.133.0)
  • python-pptx 1.0.2, Pillow 12.3.0
  • Python 3.14, Linux

dlaszlo avatar Oct 05 '26 13:10 dlaszlo

@dlaszlo thanks for the heads-up and sorry for closing the issue without having it resolved properly. I have created the PR #4594 , which should fix it once it's merged.

ceberam avatar Oct 05 '26 17:10 ceberam

@ceberam Thanks for the quick fix!

dlaszlo avatar Oct 05 '26 18:10 dlaszlo