PNG
JPG
BMP
TIFF
PPTX
Parse PPTX Formats in C#
Native and high performance PPTX document parsing using server-side Aspose.Slides for .NET APIs, without the use of any software like Microsoft or Adobe PDF.
Parse PPTX File Using C#
In order to parse PPTX file, we’ll use
API which is a feature-rich, powerful and easy to use document manipulation API for C# platform. Open
package manager, search for Aspose.Slides and install. You may also use the following command from the Package Manager Console.
Command
PM> Install-Package Aspose.Slides.NET
How to Parse PPTX Files in C#
A basic document parsing with Aspose.Slides for .NET APIs can be done with just few lines of code.
Load PPTX file.
Get all text frames.
Loop through each paragraph portion.
Get the required output like text, font etc.
System Requirements
Our APIs are supported on all major platforms and Operating Systems. Before executing the code below, please make sure that you have the following prerequisites on your system.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Windows Azure, Mono or Xamarin Platforms
- Development environment like Microsoft Visual Studio
- Aspose.Slides for .NET DLL referenced in your project - Install from NuGet using the Download button above
Parse PPTX Files - C#
//Extract Text from the Whole pptx Presentation
Presentation pptxPresentation = new Presentation(dataDir + "demo.pptx");
//Get an Array of ITextFrame objects from all slides in the PPTX
ITextFrame[] textFramesPPTX = Aspose.Slides.Util.SlideUtil.GetAllTextFrames(pptxPresentation, true);
//Loop through the Array of TextFrames
for (int i = 0; i < textFramesPPTX.Length; i++)
//Loop through paragraphs in current ITextFrame
foreach (IParagraph para in textFramesPPTX[i].Paragraphs)
//Loop through portions in the current IParagraph
foreach (IPortion port in para.Portions)
{
//Display text in the current portion
Console.WriteLine(port.Text);
//Display font height of the text
Console.WriteLine(port.PortionFormat.FontHeight);
//Display font name of the text
if (port.PortionFormat.LatinFont != null)
Console.WriteLine(port.PortionFormat.LatinFont.FontName);
}