Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 9, 2021 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/fa06076425f4fd9b9ed20591f404b529 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/fa06076425f4fd9b9ed20591f404b529 to your computer and use it in GitHub Desktop.
//Instatiate Presentation class that represents a PPTX file
Presentation pptxPresentation = new Presentation("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);
}
}
}
//Instatiate PresentationEx class that represents a PPTX file
Presentation pptxPresentation = new Presentation("demo.pptx");
//Get an Array of TextFrameEx objects from the first slide
ITextFrame[] textFramesSlideOne = SlideUtil.GetAllTextBoxes(pptxPresentation.Slides[0]);
//Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne.Length; i++)
{
//Loop through paragraphs in current TextFrame
foreach (Paragraph para in textFramesSlideOne[i].Paragraphs)
{
//Loop through portions in the current Paragraph
foreach (Portion 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
Console.WriteLine(port.PortionFormat.LatinFont.FontName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment