Parse PPTX Files using C#
Extract text and inspect text formatting in PPTX files with server-side .NET APIs.
Parse PPTX File Using C#
Use Aspose.Slides for .NET to extract text from PPTX presentations. Install the package from NuGet or run the following command in the Package Manager Console.
Command
PM> Install-Package Aspose.Slides.NET
Parse PPTX Files - C#
using var presentation = new Presentation("presentation.pptx");
var textFrames = SlideUtil.GetAllTextFrames(presentation, true);
foreach (var textFrame in textFrames)
{
foreach (var paragraph in textFrame.Paragraphs)
{
foreach (var portion in paragraph.Portions)
{
Console.WriteLine(portion.Text);
Console.WriteLine(portion.PortionFormat.FontHeight);
var latinFont = portion.PortionFormat.LatinFont;
if (latinFont is not null)
{
Console.WriteLine(latinFont.FontName);
}
}
}
}
How to Parse PPTX Files in C#
Basic document parsing with the Aspose.Slides for .NET API requires just a few lines of code.
Load the PPTX file with
Presentation.Retrieve text frames with
SlideUtil.GetAllTextFrames.Iterate through text frames, paragraphs, and portions.
Read
Text,FontHeight, andLatinFont.FontNameproperties as needed.
System Requirements
A supported .NET runtime and an Aspose.Slides for .NET package reference are required. You can use Visual Studio or another compatible C# development environment.
- .NET Framework, .NET, Mono, or Xamarin-compatible environment
- A C# development environment such as Visual Studio
- Aspose.Slides for .NET installed from NuGet
About Aspose.Slides for .NET API
Aspose.Slides for .NET reads, writes, edits, and converts PowerPoint and OpenDocument presentations. It can create presentations, work with slides and their elements, and save to formats such as PDF, XPS, HTML, TIFF, and ODP without requiring Microsoft PowerPoint or OpenOffice.Online PPTX Parser
PPTX What is PPTX File Format?
PPTX files are presentations created with Microsoft PowerPoint. Unlike the binary PPT format, PPTX uses the Office Open XML format. A presentation contains slides with text, images, formatting, animations, and other media that are shown as a slideshow.
Read More