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.

Tue Feb 09, 2021 10:21 am

Hi Team,

I am trying to remove the Images from loaded ppt file. Unable to find the code to delete.

Thanks in advance for your support.
Here is my code.

Presentation ppt = new Presentation();
ppt.LoadFromStream(streamUrl, FileFormat.Pptx2013);
ISlide slide = ppt.Slides[0];

foreach (IShape shape in slide.Shapes)
{
if (shape is SlidePicture)
{
if (shape.AlternativeText == "image1")
{
//trying to code to remove image/picture
}
}
}


--//Any other ways also appreciated.

Thanks & Regards

saleembaigmirza
 
Posts: 21
Joined: Fri Nov 13, 2020 4:15 pm

Tue Feb 09, 2021 11:22 am

HI Team,

I have added below code,

if (shape.AlternativeText == "image1")
{
//trying to code to remove image/picture
(shape as SlidePicture).PictureFill.Picture.EmbedImage = null;
}

With the above code i can able to remove images but, i am getting 'No Picture' text in that place as shown in attachment

saleembaigmirza
 
Posts: 21
Joined: Fri Nov 13, 2020 4:15 pm

Wed Feb 10, 2021 7:07 am

Hello

Thanks for your inquiry.
Please refer to the following code to remove the Images.
If this doesn’t meet your needs well, please provide your input file along with your desired output file. Then we will investigate further.
Code: Select all
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("test.pptx", FileFormat.Pptx2013);
            ISlide slide = ppt.Slides[0];

            for (int i=0; i < slide.Shapes.Count; i++)
            {
                if(slide.Shapes[i] is SlidePicture)
                {
                    if (slide.Shapes[i].AlternativeText == "image1")
                    {
                        slide.Shapes.RemoveAt(i);
                        i--;
                    }
                }
            }
            ppt.SaveToFile("result.pptx", FileFormat.Pptx2013);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Feb 22, 2021 1:49 am

Hello,

Has your issue been resolved? If not, could you please provide your input file to us for further investigation?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Mar 05, 2021 9:35 am

Hi Brian,

Yes it helps.
Thanks for your response.

saleembaigmirza
 
Posts: 21
Joined: Fri Nov 13, 2020 4:15 pm

Fri Mar 05, 2021 11:55 am

You are welcome.
If you encounter any issues related to our products in the future, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Presentation