<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Using Aspose Slides for Java, is it possible to interact with a picture placeholder
that has been put on a masterslide?
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Our
client has a PPTX file that contains picture placeholders – they want images to
be added to these placeholders programmatically and formatted in the same way it would be if a user opened the PPTX file in PowerPoint and clicked the button in the middle of the placeholder (which enables the user to browse for an image).
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>I have uploaded an example PPTX file, which contains a very simple picture placeholder.
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Thanks,
<span style=“font-size:11.0pt;font-family:“Calibri”,“sans-serif”;
mso-fareast-font-family:“Times New Roman”;mso-bidi-font-family:“Times New Roman”;
mso-ansi-language:EN-GB;mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Martin
I have tried to understand your problem statement and based on my understating you want to add picture in a shape by using Aspose.Slides. Please visit this documentation link to fill shape with picture.
Thanks for your reply. I did try this approach but I am looking to make use of PowerPoint’s placeholders for the following reasons:
- Using placeholders in PowerPoint the picture is automatically cropped to the size of the placeholder.
- Using placeholders a user can change the layout of a slide (Home->Layout).
You might want to try adding a placeholder yourself to a presentation to see what I mean by ‘placeholder’:
- In PowerPoint, go to the ‘View’ menu.
- Click ‘Master Layout’
- Right click in the left-hand pane and choose ‘insert layout’
- Click ‘Insert Placeholder’ in the top sub-menu and then choose ‘Picture’
- Draw the placeholder shape on the new layout
- Close the ‘master layout’
- On a slide in the presentation, right click on the slide in the left-hand pane and select ‘Layout’ and choose the new layout you just added.
- You should then see a ‘placeholder’ - you can click on the button in the middle to upload a picture.
If Aspose Slides for Java cannot interact with placeholders then I might be able to use the technique you described if I can get the image to be cropped to fit. Is this possible?
Please accept my apology for late response. Please use the following code snippet to fill the shape with image. Please also visit the following documentation link.
//Instantiate PrseetationEx class that represents the PPTX PresentationEx pptxPresentation = new PresentationEx(); //Get the first slide SlideEx pptxSlide = pptxPresentation.getSlides().get(0);
//Add autoshape of rectangle type int shapeIndex = pptxSlide.getShapes().addAutoShape(ShapeTypeEx.RECTANGLE, 0, 0, 1024, 768); ShapeEx pptxAutoShape = pptxSlide.getShapes().get(shapeIndex);
//Set the fill type to Picture pptxAutoShape.getFillFormat().setFillType(FillTypeEx.PICTURE);
//Set the picture fill mode pptxAutoShape.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillModeEx.STRETCH);
Your example STRETCHES the images to fill the shape (as the name of the enum PictureFillModeEx.STRETCH suggests), which is not much use unless the source image is very similar in aspect ratio to the shape.
I want them to be CROPPED to fill the shape.
Please let me know if this is possible, or if my question/issue is still not clear.
I regret to share with you that Aspose.Slide does not support the requested feature. However, I
have logged a new feature request as SLIDESJAVA-32532 in our issue
tracking system to support it. You will be notified via this forum
thread once this feature is available.
I feel you have launched the same query in a separate thread. I have already shared my response with you here. Please share, if I may help you further in this regard.