Bug 65167 - Not possible to set placeholder picture
Summary: Not possible to set placeholder picture
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 5.0.0-FINAL
Hardware: PC
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-05 00:30 UTC by Joren
Modified: 2021-03-05 00:30 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joren 2021-03-05 00:30:12 UTC
In working with POI 5.0.0 (congratulations on the release!), there appears to be no way to use picture data to fill a layout-defined picture placeholder.

Let's say I'm adding slides using the SlideLayout.PIC_TX layout.  This layout has three placeholders:  Title, picture, and text.  Calling slide.getPlaceholders() only returns instances of XLSFAutoShape, which extend XSLFTextShape, even for the picture placeholder.  I would expect the picture placeholder shape to provide a method similar to what XSLFPictureShape provides for using XSLFPictureData to define the picture.

The workaround people appear to be using is to save the anchor of the picture placeholder, delete the placeholder shape, then call slide.createPicture(pictureData) and set the returned shape's anchor to the same as the placeholder's.  See e.g. the answer provided for https://stackoverflow.com/questions/35721547/how-to-add-image-to-image-placeholder-added-in-pptx-using-apache-poi-api

This will "work" in the sense that the picture will be at the same location and size the placeholder defined, but deleting the placeholder and replacing it with a new shape means that the placeholder can't be used to interact with and change the layout of the picture, either programmatically or as a user editing the slide working with a slide master.

The shape returned by the getPlaceholder() call should be an abstract class that the user could instance-check to see if it's a picture shape, a text shape, or some other shape, and handle it accordingly.

Happy to provide further information as needed, and thanks for bearing with me as a newbie to the Apache Bugzilla and to POI as well.  Thank you,

-- Joren