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 IPortionConstructors
| Signature | Description |
|---|---|
Portion() | Create a new empty portion. |
Portion(String text) | Create a portion with the given text. |
Properties
| Property | Type | Access | Description |
|---|---|---|---|
getText() / setText(String) | String | Read/Write | Text content of this run. |
getPortionFormat() | IPortionFormat | Read | Character-level formatting (font, size, bold, color, etc.). |
getSlide() | IBaseSlide | Read | Parent slide. |
getPresentation() | IPresentation | Read | Parent 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()