We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

traversing all the components of a powerpoint file

Hello everyone

I used a diff library and it was great. But I was asked to try syncfusion in hopes of conversion. So I checked the documentation and started a bit of testing. I have the following inquries and would appreciate your help on this matter

https://help.syncfusion.com/file-formats/presentation/document-object-model

  1. Is this up to date? I couldn't find IOfficeChart when writing the code but I did find IPresentationChart so please confirm that both are one and the same
  2. I would like to traverse all the components of the slide. If the above link is up to date, please confirm the below code. Thank you
  3. Third and final inquiry is at the last line of the code

Code

private void Form1_Load(object sender, EventArgs e)

{

IPresentation pptxDoc = Presentation.Open("test 41c 42c.pptx");

foreach (ISlide isld in pptxDoc.Slides)

foreach (IShape ishp in isld.Shapes)

Traverse(ishp);

pptxDoc.Close();

}


private void Traverse(IShape ishp)

{

if (ishp is IPresentationChart) ; //do something

else if (ishp is ITable) ; //do something

else if (ishp is IPicture) ; //do something

else if (ishp is IGroupShape)

            {

                IGroupShape groupShape = ishp as IGroupShape;

                foreach (IShape childShape in groupShape.Shapes)

                    Traverse(childShape, width, isld);

            }

else; //do something <-- it's an AutoShape <-- how do i access it? i only found ishape; didnt find autoshape

}



2 Replies 1 reply marked as answer

AN Anto Nihil Sahaya Raj Syncfusion Team October 20, 2022 11:18 AM

Hi Omar,

Please find the details below,

Regarding - Is this up to date? I couldn't find IOfficeChart when writing the code but I did find IPresentationChart so please confirm that both are one and the same:
Yes, above link is up to date. Internally we use the IOfficeChart to create or modify the charts in PowerPoint Presentation document. We set the IOfficeChart’s properties through the IPresentationChart. So that we mentioned IOfficeChart in DOM level.

Please refer the below link to know more about working with charts in PowerPoint Presentation document,
https://help.syncfusion.com/file-formats/presentation/working-with-charts#creating-a-chartfrom-scratch

Regarding - I would like to traverse all the components of the slide. If the above link is up to date, please confirm the below code and Third and final inquiry is at the last line of the code:
We recommended you to use SlideItemType enum to traverse all the components of the slide. Please use the below code to achieve your requirement,

private void Traverse(IShape ishp)

{

if (ishp.SlideItemType is SlideItemType.Chart) ; //do something

else if (ishp.SlideItemType is SlideItemType.Table) ; //do something

else if (ishp.SlideItemType is SlideItemType.Picture) ; //do something

else if (ishp.SlideItemType is SlideItemType.GroupShape)

   {

      IGroupShape groupShape = ishp as IGroupShape;

      foreach (IShape childShape in groupShape.Shapes)

      Traverse(childShape, width, isld);

   }

else if (ishp.SlideItemType is SlideItemType.AutoShape) ; //do something

}

Please refer the below link to know more about accessing the Master and Layout slides in PowerPoint Presentation document,
https://help.syncfusion.com/file-formats/presentation/create-read-edit-master-slide-and-layout-slide-in-c-sharp

Please let me know if you have any questions regarding this.

Regards,
Anto Nihil S

If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Marked as answer

OM omar October 20, 2022 02:22 PM

thank you. you didn't answer the second half of my 3rd inquiry (how to deal with autoshape) but i will consider your response the answer to my inquiries. thank you again. i'll start a new post with a new question :D


Loader.
Live Chat Icon For mobile
Up arrow icon