Portion — Aspose.Slides FOSS for Java API Reference

The Portion class represents a text run within a paragraph. Each portion can have its own character-level formatting. It implements IPortion.

Package: org.aspose.slides.foss

import org.aspose.slides.foss.*;
public class Portion implements IPortion

Constructors

SignatureDescription
Portion()Create a new empty portion.
Portion(String text)Create a portion with the given text.

Properties

PropertyTypeAccessDescription
getText() / setText(String)StringRead/WriteText content of this run.
getPortionFormat()IPortionFormatReadCharacter-level formatting (font, size, bold, color, etc.).
getSlide()IBaseSlideReadParent slide.
getPresentation()IPresentationReadParent presentation.

Usage Examples

Read Portion Text and Format

import org.aspose.slides.foss.*;

Presentation prs = new Presentation("deck.pptx");
IAutoShape shape = (IAutoShape) prs.getSlides().get(0).getShapes().get(0);
IParagraph para = shape.getTextFrame().getParagraphs().get(0);

for (int i = 0; i < para.getPortions().size(); i++) {
    IPortion portion = para.getPortions().get(i);
    System.out.println("Text: " + portion.getText());
}

Create a Portion with Text

Portion portion = new Portion("Bold text");
// Apply formatting through portion.getPortionFormat()

See Also