Open and read PowerPoint file in C# and VB.NET

GemBox.Presentation supports reading PowerPoint presentations in C# and VB.NET from a file path or a stream. This functionality is exposed through the PresentationDocument.Load static method overloads. The presentation file format is specified through LoadOptions derived classes.

The following example shows how you can read a PowerPoint presentation from a file path, iterate over all Shape, TextParagraph and TextRun elements, and output text for all TextRun elements with font-weight information to the Console output.

Text read with GemBox.Presentation
Screenshot of text read with GemBox.Presentation
Upload your file (Drag file here)
using System;
using System.Linq;
using System.Text;
using GemBox.Presentation;

class Program
    static void Main()
        // If using Professional version, put your serial key below.

        var presentation = PresentationDocument.Load("%InputFileName%");

        var sb = new StringBuilder();

        var slide = presentation.Slides[0];

        foreach (var shape in slide.Content.Drawings.OfType<Shape>())
            sb.AppendFormat("Shape ShapeType={0}:", shape.ShapeType);

            foreach (var paragraph in shape.Text.Paragraphs)
                foreach (var run in paragraph.Elements.OfType<TextRun>())
                    var isBold = run.Format.Bold;
                    var text = run.Text;

                    sb.AppendFormat("{0}{1}{2}", isBold ? "<b>" : "", text, isBold ? "</b>" : "");



Imports System
Imports System.Linq
Imports System.Text
Imports GemBox.Presentation

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.

        Dim presentation = PresentationDocument.Load("%InputFileName%")

        Dim sb = New StringBuilder()

        Dim slide = presentation.Slides(0)

        For Each shape In slide.Content.Drawings.OfType(Of Shape)

            sb.AppendFormat("Shape ShapeType={0}:", shape.ShapeType)

            For Each paragraph In shape.Text.Paragraphs

                For Each run In paragraph.Elements.OfType(Of TextRun)

                    Dim isBold = run.Format.Bold
                    Dim text = run.Text

                    sb.AppendFormat("{0}{1}{2}", If(isBold, "<b>", ""), text, If(isBold, "</b>", ""))



    End Sub
End Module

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Presentation yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.