Read an image in Powerpoint file using c# Interop

462 Views Asked by At

I need to parse a powerpoint file using c# Interop library.
I know how to get text value but I don't know how to get picture data.

For example, the powerpoint slide is composed by a text and a picture, like below. enter image description here

With this code I'm able to identify the Title text but how to get the image data?

private static void parse(string pptPath)
{

     Application app = new Application();
     string presentation = pptPath;

     Presentation p = app.Presentations.Open(presentation, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);


     foreach (Slide slide in p.Slides)
     {
          foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in slide.Shapes)
          {                        
                if (shape.HasTextFrame == Microsoft.Office.Core.MsoTriState.msoTrue)
                {
                    var textFrame = shape.TextFrame;
                    if (textFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                    {
                        var textRange = textFrame.TextRange;
                        Console.WriteLine(textRange.Text.ToString());
                    }

                }


            }

        }


}
1

There are 1 best solutions below

0
On

I think there is no ways to read the image in PowerPoint using interop.