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 Apr 27, 2022 12:18 am

Good morning dear team,
I'd very much appreciate your assistance in completing this recursive function. I am trying to go over all the content of a slide and capturing/printing its text. From my research, a slide can contain either a shape or a group. A shape can be a picture, a chart, a table, a textbox, or anything else powerpoint allows you to place. A group contains multiple shapes.

Here is what I have so far. Please complete it for me if I'm missing anything. Thank you

Code: Select all
foreach (ISlide slide in presentation.Slides)
                    {
                        foreach (IShape ishape in slide.Shapes)
                        {
                            GetTextFromShape(ishape);
                        }
                    }

private void GetTextFromShape(IShape ishape)
        {
            if (ishape is GroupShape)
            {
                foreach (IShape ishapeInGroup in ((GroupShape)ishape).Shapes)
                    GetTextFromShape(ishapeInGroup);
            }

            else
            {
                if (ishape is ITable)
                    GetTextFromTable(ishape);

                else if (ishape is IAutoShape)
                    GetTextFromIAutoShape(ishape);
            }
        }

        private static void GetTextFromTable(IShape ishape)
        {
            //get text
        }

        private static void GetTextFromIAutoShape(IShape ishape)
        {
            //get text
        }

wildheart25c
 
Posts: 2
Joined: Fri Mar 06, 2020 5:44 am

Wed Apr 27, 2022 7:42 am

Hello,

Thanks for your post.
In order to better fulfill your requirement, we will add a generic method to extract text from all PPT elements. Our Dev team will review our product internal processing mechanism and encapsulate all the traversal codes. The new feature was logged using the ticket SPIREPPT-1933. Once it is available, we will inform you asap.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Presentation