officefileapi-405430-presentation-api-extract-presentation-content.md
Code samples in this help topic extract various content from presentations: shape text, images, slide notes, and so on.
Use the following collections to obtain slides and their content:
Examples below use the following techniques to obtain slide content correctly:
The order of elements in the Shapes collection does not necessarily match the visual order. To process shapes from top to bottom or left to right, sort them by coordinates. Examples in this topic use the System.Linq namespace to sort elements.
You can identify and skip certain shape types. For example, the Shapes collection includes a slide number placeholder shape. Use the CommonShape.PlaceholderSettings.Type property to identify and skip this shape.
You can obtain only shapes that contain text. Check that the TextAreaBase.Text property is not an empty string.
Use the Shape‘s TextAreaBase.Text property to obtain the shape text.
The following code sample obtains text from the second slide of the Sample.pptx presentation. Shapes with text are obtained in the following order - top and leftmost shapes go first:
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract text from the second slide
string slidesText = "";
#region Sort shapes
var sortedShapes = presentation.Slides[1].Shapes
.Where(shape => shape is Shape && ((Shape)shape).TextArea != null)
.OrderBy(shape => shape.Y)
.ThenBy(shape => shape.X);
#endregion
foreach (var shape in sortedShapes) {
if (shape is Shape textShape) {
string shapeText = textShape.TextArea.Text;
#region Filter shapes
if (textShape.PlaceholderSettings?.Type == PlaceholderType.SlideNumber
|| string.IsNullOrWhiteSpace(shapeText)) continue;
#endregion
slidesText += shapeText + "\r\n";
}
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract text from the second slide
Dim slidesText As String = ""
' Sort shapes
Dim sortedShapes = presentation.Slides(1).Shapes _
.Where(Function(shape) TypeOf shape Is Shape AndAlso CType(shape, Shape).TextArea IsNot Nothing) _
.OrderBy(Function(shape) shape.Y) _
.ThenBy(Function(shape) shape.X)
For Each shape In sortedShapes
If TypeOf shape Is Shape Then
Dim textShape As Shape = CType(shape, Shape)
Dim shapeText As String = textShape.TextArea.Text
' Filter shapes
If textShape.PlaceholderSettings?.Type = PlaceholderType.SlideNumber _
OrElse String.IsNullOrWhiteSpace(shapeText) Then
Continue For
End If
slidesText &= shapeText & vbCrLf
End If
Next
End Sub
Show Extraction Result
User Feedback
Developers who use DevExpress products often highlight the following key benefits:
💹 Comprehensive product lineup
DevExpress offers a wide range of tools — 19 products, including 15 control libraries — along with cross-platform packages. Developers can select what they need for a specific project or use a full-featured suite.
💭 Try before you buy
DevExpress provides access to online demos and a free 30-day trial, allowing developers to evaluate whether the tools meet their needs.
The company also backs its products with a 60-day unconditional money-back guarantee.
❣️User-friendly Tools
Many developers highlight the clarity and optimization of DevExpress controls compared to alternatives. With an intuitive API, the tools are easy to set up and use across a variety of scenarios.
The following code sample obtains text from all slides of the Sample.pptx presentation. Shapes with text are obtained in the following order - top and leftmost shapes go first:
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract text from all slides
int slideNumber = 0;
string slidesText = "";
foreach (var slide in presentation.Slides) {
#region Sort shapes
var sortedShapes = slide.Shapes
.Where(shape => shape is Shape && ((Shape)shape).TextArea != null)
.OrderBy(shape => shape.Y)
.ThenBy(shape => shape.X);
#endregion
foreach (var shape in sortedShapes) {
if (shape is Shape textShape) {
string shapeText = textShape.TextArea.Text;
#region Filter shapes
if (textShape.PlaceholderSettings?.Type == PlaceholderType.SlideNumber
|| string.IsNullOrWhiteSpace(shapeText)) continue;
#endregion
slidesText += shapeText+"\r\n";
}
}
slideNumber++;
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract text from all slides
Dim slideNumber As Integer = 0
Dim slidesText As String = ""
For Each slide In presentation.Slides
' Sort shapes
Dim sortedShapes = slide.Shapes _
.Where(Function(shape) TypeOf shape Is Shape AndAlso CType(shape, Shape).TextArea IsNot Nothing) _
.OrderBy(Function(shape) shape.Y) _
.ThenBy(Function(shape) shape.X)
For Each shape In sortedShapes
If TypeOf shape Is Shape Then
Dim textShape As Shape = CType(shape, Shape)
Dim shapeText As String = textShape.TextArea.Text
' Filter shapes
If textShape.PlaceholderSettings?.Type = PlaceholderType.SlideNumber _
OrElse String.IsNullOrWhiteSpace(shapeText) Then
Continue For
End If
slidesText &= shapeText & vbCrLf
End If
Next
slideNumber += 1
Next
End Sub
Show Extraction Result
The 2020s bring major shifts in .NET development, with technologies like Blazor and .NET MAUI enabling more integrated, cross-platform solutions.
DevExpress supports these platforms with a growing set of UI components for web, mobile, and desktop applications.
For web developers outside the .NET ecosystem, our DevExtreme library offers rich controls for React, Angular, and Vue, with strong TypeScript and SCSS support. On the desktop side, we continue to enhance our WinForms and WPF tools with modern features like DirectX rendering and HTML/CSS formatting.
User Feedback
Developers who use DevExpress products often highlight the following key benefits:
💹 Comprehensive product lineup
DevExpress offers a wide range of tools — 19 products, including 15 control libraries — along with cross-platform packages. Developers can select exactly what they need for a specific project or use a full-featured suite.
💭 Try before you buy
DevExpress provides access to online demos and a free 30-day trial, allowing developers to evaluate whether the tools are intuitive and meet their needs.
The company also backs its products with a 60-day unconditional money-back guarantee.
❣️User-friendly Tools
Many developers highlight the clarity and optimization of DevExpress controls compared to alternatives. With an intuitive API, the tools are easy to set up and use across a variety of scenarios.
The following code sample uses the Shapes.Find method to find the TextBox 3 shape on the first slide and then extracts the text from its second paragraph:
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
//Extract text from the specific shape's paragraph
string paraText = "";
Shape shape = presentation.Slides[0].Shapes.Find<Shape>(s => s.Name == "TextBox 3");
paraText = shape.TextArea.Paragraphs[1].Text;
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract text from the specific shape's paragraph
Dim paraText As String = ""
Dim shape As Shape = presentation.Slides(0).Shapes.Find(Of Shape)(Function(s) s.Name = "TextBox 3")
paraText = shape.TextArea.Paragraphs(1).Text
End Sub
Show Extraction Result
DevExpress supports these platforms with a growing set of UI components for web, mobile, and desktop applications.
Use the Slide.Notes collection to obtains notes of a specific slide.
The following code sample obtains the note text from the first slide of the Sample.pptx presentation:
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract note text from the first slide
string slideNoteText = "";
foreach (var noteShape in presentation.Slides[0].Notes.Shapes) {
if (noteShape is Shape textNoteShape) {
string noteShapeText = textNoteShape.TextArea.Text;
#region Filter shapes
if (textNoteShape.PlaceholderSettings?.Type == PlaceholderType.SlideNumber
|| string.IsNullOrWhiteSpace(noteShapeText)) continue;
#endregion
slideNoteText += noteShapeText + "\r\n";
}
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract note text from the first slide
Dim slideNoteText As String = ""
For Each noteShape In presentation.Slides(0).Notes.Shapes
If TypeOf noteShape Is Shape Then
Dim textNoteShape As Shape = CType(noteShape, Shape)
Dim noteShapeText As String = textNoteShape.TextArea.Text
' Filter shapes
If textNoteShape.PlaceholderSettings IsNot Nothing AndAlso
textNoteShape.PlaceholderSettings.Type = PlaceholderType.SlideNumber Then
Continue For
End If
If String.IsNullOrWhiteSpace(noteShapeText) Then Continue For
slideNoteText &= noteShapeText & vbCrLf
End If
Next
End Sub
Show Extraction Result
Introduction text about DevExpress.
The following code sample obtains the note body text from the second slide of the Sample.pptx presentation:
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract body note text from the specific slide
string notesText = "";
foreach (var noteShape in presentation.Slides[1].Notes.Shapes) {
if (noteShape is Shape textNoteShape
&& textNoteShape.PlaceholderSettings.Type == PlaceholderType.Body) {
string noteShapeText = textNoteShape.TextArea.Text;
#region Filter shapes
if (textNoteShape.PlaceholderSettings?.Type == PlaceholderType.SlideNumber
|| string.IsNullOrWhiteSpace(noteShapeText)) continue;
notesText += noteShapeText + "\r\n";
#endregion
}
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract body note text from the specific slide
Dim notesText As String = ""
For Each noteShape In presentation.Slides(1).Notes.Shapes
If TypeOf noteShape Is Shape Then
Dim textNoteShape As Shape = CType(noteShape, Shape)
If textNoteShape.PlaceholderSettings IsNot Nothing AndAlso
textNoteShape.PlaceholderSettings.Type = PlaceholderType.Body Then
Dim noteShapeText As String = textNoteShape.TextArea.Text
' Filter shapes
If textNoteShape.PlaceholderSettings.Type = PlaceholderType.SlideNumber _
OrElse String.IsNullOrWhiteSpace(noteShapeText) Then
Continue For
End If
notesText &= noteShapeText & vbCrLf
End If
End If
Next
End Sub
Show Extraction Result
Key Benefits
The following code sample obtains note text from all slides of the Sample.pptx presentation. Note shapes with text are obtained in the following order - top and leftmost shapes go first:
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract note text from all slides
string notesText = "";
foreach (var slide in presentation.Slides) {
if (slide.Notes.Shapes.Any()) {
#region Sort shapes
var sortedNoteShapes = slide.Notes.Shapes
.Where(shape => shape is Shape && ((Shape)shape).TextArea != null)
.OrderBy(shape => shape.Y)
.ThenBy(shape => shape.X);
#endregion
foreach (var noteShape in sortedNoteShapes) {
if (noteShape is Shape textNoteShape) {
string noteShapeText = textNoteShape.TextArea.Text;
#region Filter shapes
if (textNoteShape.PlaceholderSettings?.Type == PlaceholderType.SlideNumber
|| string.IsNullOrWhiteSpace(noteShapeText)) continue;
notesText += noteShapeText + "\r\n";
#endregion
}
}
}
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract note text from all slides
Dim notesText As String = ""
For Each slide In presentation.Slides
If slide.Notes.Shapes.Any() Then
' Sort shapes
Dim sortedNoteShapes = slide.Notes.Shapes. _
Where(Function(shape) TypeOf shape Is Shape AndAlso CType(shape, Shape).TextArea IsNot Nothing). _
OrderBy(Function(shape) shape.Y). _
ThenBy(Function(shape) shape.X)
For Each noteShape In sortedNoteShapes
If TypeOf noteShape Is Shape Then
Dim textNoteShape As Shape = CType(noteShape, Shape)
Dim noteShapeText As String = textNoteShape.TextArea.Text
' Filter shapes
If textNoteShape.PlaceholderSettings IsNot Nothing AndAlso
textNoteShape.PlaceholderSettings.Type = PlaceholderType.SlideNumber Then
Continue For
End If
If String.IsNullOrWhiteSpace(noteShapeText) Then
Continue For
End If
notesText &= noteShapeText & vbCrLf
End If
Next
End If
Next
End Sub
Show Extraction Result
Introduction text about DevExpress.
Key Benefits
Describe key benefits to the customer.
The following code sample obtains pictures from the second slide of the Sample.pptx presentation. The sample saves obtained images to files on disk. Topmost and leftmost pictures go first.
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract pictures from the second slide
#region Sort shapes
var sortedShapes = presentation.Slides[1].Shapes
.Where(shape => shape is PictureShape)
.OrderBy(shape => shape.Y)
.ThenBy(shape => shape.X);
#endregion
byte imageCount = 0;
foreach (PictureShape pictureShape in sortedShapes) {
pictureShape.Image.Save("Slide2_Picture" + imageCount + ".png", DXImageFormat.Png);
imageCount++;
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract pictures from the second slide
' Sort shapes
Dim sortedShapes = presentation.Slides(1).Shapes _
.Where(Function(shape) TypeOf shape Is PictureShape) _
.OrderBy(Function(shape) shape.Y) _
.ThenBy(Function(shape) shape.X)
Dim imageCount As Byte = 0
For Each shape In sortedShapes
Dim pictureShape As PictureShape = CType(shape, PictureShape)
pictureShape.Image.Save($"Slide2_Picture{imageCount}.png", DXImageFormat.Png)
imageCount += 1
Next
End Sub
The following code sample obtains pictures from all slides of the Sample.pptx presentation. The sample saves obtained images to files on disk. Topmost and leftmost pictures go first.
public static void Main(string[] _) {
Presentation presentation =
new Presentation(File.ReadAllBytes(@"data\Sample.pptx"));
// Extract pictures from all slides
int slideNumber = 0;
foreach (var slide in presentation.Slides) {
#region Sort shapes
var sortedShapes = slide.Shapes
.Where(shape => shape is PictureShape)
.OrderBy(shape => shape.Y)
.ThenBy(shape => shape.X);
#endregion
byte imageCount=0;
foreach (PictureShape pictureShape in sortedShapes) {
pictureShape.Image.Save("Slide" + slideNumber +"_Picture"+imageCount+".png", DXImageFormat.Png);
imageCount++;
}
slideNumber++;
}
}
Sub Main(args As String())
Dim presentation As New Presentation(File.ReadAllBytes("data\Sample.pptx"))
' Extract pictures from all slides
Dim slideNumber As Integer = 0
For Each slide In presentation.Slides
' Sort shapes
Dim sortedShapes = slide.Shapes _
.Where(Function(shape) TypeOf shape Is PictureShape) _
.OrderBy(Function(shape) shape.Y) _
.ThenBy(Function(shape) shape.X)
Dim imageCount As Byte = 0
For Each shape In sortedShapes
Dim pictureShape As PictureShape = CType(shape, PictureShape)
pictureShape.Image.Save($"Slide{slideNumber}_Picture{imageCount}.png", DXImageFormat.Png)
imageCount += 1
Next
slideNumber += 1
Next
End Sub