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.

Thu Feb 21, 2019 7:02 am

As we know, each element of a slide has a unique id. There is any APIs of Spire.Presentation which allows get shape by id?

pic.png


As shown in the example, I wanna get SlidePicture which has id=5.

AdamShakhabov
 
Posts: 40
Joined: Wed Sep 26, 2018 12:03 pm

Thu Feb 21, 2019 9:38 am

Dear Adam,

Thank you for contacting us.
There is no way to get shape by the id you referred. Actually, the id of p:cNvPr is allowed to be the same, to verify it, you could modify the id of several pictures to be the same in the xml, after packaging the revised xml to a new presentation, you will see the new file doesn't have any problem. For your situation, I advise you to get the shape by shape name. Please refer to the following code. If there is any question, please feel free to write back.
Code: Select all
Presentation PPT = new Presentation();
PPT.LoadFromFile("Input.pptx");
foreach (IShape s in PPT.Slides[0].Shapes)
{
    if (s is SlidePicture)
    {
        SlidePicture ps = s as SlidePicture;
        if (ps.Name == "Picture 4")
        {
            //...
        }
    }
}
PPT.SaveToFile("output.pptx", Spire.Presentation.FileFormat.Pptx2013);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Thu Feb 28, 2019 8:26 am

Hi,

Greetings from E-iceblue!
Is my answer helpful to you?
Thanks in advance for your valuable feedback and time.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1195
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.Presentation