Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Wed Jul 31, 2024 1:01 pm

Hi Team,

I need to generate a PowerPoint slide which should contain a shape with text 'Click Icon to add picture​' and a dummy icon. When user clicks on Icon, it should open 'Insert Picture' dialog box and allow the user to select the desired the image which fits into the shape.

Could you please let us know if this is possible? I'm attaching the image for your reference by highlighting the required things.

Thanks in Advance!!

praveenkasani
 
Posts: 14
Joined: Mon Mar 04, 2024 11:21 am

Thu Aug 01, 2024 8:27 am

Hi,

Thank you for inquiry.
In order to investigate your issue accurately, if you had this sample documentation, please also provide us with it so that we can further analyze the document data.You can upload here or send them to us via email(support@e-iceblue.com). Thanks in advance.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Thu Aug 01, 2024 1:34 pm

Hi Amin,

Thanks for the reply.

We don't have any document for this. Requirement is very simple i.e. can we place a Insert Picture tool as I have shown in the image of previous post question?

When user clicks on the icon available on the slide, It has to open a 'Insert Picture' dialog box so that user can select the desired image. I'm attaching the screen shot from a PPTX file.

Please check the attached image.

Thanks for your help in advance!!

praveenkasani
 
Posts: 14
Joined: Mon Mar 04, 2024 11:21 am

Fri Aug 02, 2024 7:05 am

Hi,

Thank you for your feedback.
After further investigation, Microsoft PowerPoint can achieve the function of calling the dialog box to add images by inserting Placeholder in Slide Master, as shown in the screenshot below.
Image
You can use the sample code to achieve this feature. The attachment is my result document for your reference. If there is any other issues, just feel free to write back.
Code: Select all
Presentation ppt = new Presentation();
            ppt.SlideSize.Type = SlideSizeType.Screen16x9;
            //Get the first master
            IMasterSlide masterSlide = ppt.Masters[0];
            //Add image selection tool
            masterSlide.Layouts[6].InsertPlaceholder(InsertPlaceholderType.Picture, new RectangleF(300, 150, 300, 300));
            ISlide side = ppt.Slides[0];
            side.Layout = masterSlide.Layouts[6];
            ppt.SaveToFile(@"Result.pptx", FileFormat.Pptx2013);


Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Tue Aug 06, 2024 7:20 am

Hi Amin,

Thanks for solution. This resolved my issue.

Regards,
Praveen Kasani

praveenkasani
 
Posts: 14
Joined: Mon Mar 04, 2024 11:21 am

Tue Aug 06, 2024 9:38 am

Hello,

Thanks for your reply.
I'm glad to hear this news. If you have any other questions, please feel free to write to me.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Wed Aug 14, 2024 6:18 am

Hi Amin,

Master Slide Layout is getting applied to all the slides in the PPT but I want this master slide layout to only to the first slide. I tried the below code but this is throwing exceptions for other Slides. Please suggest how to make master layout applicable only to the first slide.

Code: Select all
ppt.Masters.CleanUpDesigns();
ppt.Slides[0].layout = null;


Thanks in Advance !!

praveenkasani
 
Posts: 14
Joined: Mon Mar 04, 2024 11:21 am

Wed Aug 14, 2024 9:59 am

Hello,

Thanks for your inquiry. You can refer to the following code to set the master slide layout for other slides. If this scenario is not suitable for your situation, you can provide more detailed code and documentation for us to further investigate.

Code: Select all
    Presentation ppt = new Presentation();
            ppt.SlideSize.Type = SlideSizeType.Screen16x9;
            ISlide side = ppt.Slides[0];
            //Save default slide layout
            ILayout defaultLayout = side.Layout;
            for (int i = 0; i < 4; i++)
            {
                ISlide sideAnother = ppt.Slides.Append();
                sideAnother.Layout = defaultLayout;
            }       
            //Get the first master version
            IMasterSlide masterSlide = ppt.Masters[0];
            //Add image selection tool
            masterSlide.Layouts[6].InsertPlaceholder(InsertPlaceholderType.Picture, new RectangleF(300, 150, 300, 300));
            side.Layout = masterSlide.Layouts[6];
            ppt.SaveToFile("Result.pptx", FileFormat.Pptx2013);


Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.Presentation