We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem of portion format writing

Hi, there is some problem with writing portion format. You can see from my code snippet:
Slides slides = presentation.getSlides();

Slide slide = slides.get(0);

TextFrame textFrame = slide.getShapes().get(2).getTextFrame();

Paragraphs paragraphs = textFrame.getParagraphs();

Paragraph paragraph = paragraphs.get(0);

Portions portions = paragraph.getPortions();

Portion portion = portions.get(0);

System.out.println(portion.getText()); // "At the end of this class, students will be able to:"
System.out.println(portion.isFontBold()); // return true


Portion newPortion = new Portion();

newPortion.setText(“changed, should be bold”);


presentation.write(new FileOutputStream(outputFile));

If you open output file you will see that text is not bold.

Can you have look at this.

Thanks, Ivica.


I have the exact same problem with some setter methods in the Portion class.

I have written a small Java component that translates HTML documents into Aspose.Slides API calls on a TextFrame object (an HTML renderer for text frames).

Below is the method that deals with rendering text intermixed with STRONG, U, EM and FONT tags, into a Portions collection. The basic principle is to call the appropriate setter method on a Portion object whenever one of the formatting tags is encountered. For exemple, encountering a STRONG element results in a call to setFontBold(true) on the portion.

* Recursively renders HTML content into a Paragraph's Portions collection.
private void renderHtmlInPortions(Portions portions, Portion parentPortion, Element e)
throws PptException {

// Iterates over the sibling nodes at this level of nesting.
Iterator iter = e.content().iterator();
while (iter.hasNext()) {
Node n = (Node) iter.next();

Portion portion = PptUtils.clonePortion(parentPortion);

if (n.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
portion.setText(((Text) n).getText());
else if (n.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
// Does the appropriate setting on the portion, according to the element's name.
Element x = (Element) n;
if (x.getName().equals("STRONG")) {
else if (x.getName().equals("U")) {
else if (x.getName().equals("EM")) {
else if (x.getName().equals("FONT")) {
// Reads the color from the "color" attribute's value.
Attribute a = x.attribute("color");
if (a != null) {
// Removes the leading '#'.
String s = a.getValue().substring(1);
// Parses to an int.
int colorCode = Integer.parseInt(s, 16);
portion.setFontColor(new Color(colorCode));
// Makes a recursive call to render nested nodes.
renderHtmlInPortions(portions, portion, x);

This worked fine with Aspose.Slides version But since i've been using version, it doesn't work anymore. Only the setFontColor() still works.

This is probably a bug introduced in the last or previous release.

It would be nice to have it fixed ;)


We will investigate the problem and try to fix asap.
Thank you for the examples.

Hello Ivica,

It looks like we came across the same problem in our Aspose.Slides for RS product.

Paragraph and Portion objects have many dependencies on TextFrame, Shape and Master slide so
it’s not possible to set Portion properties before it’s attached to the real TextFrame.

You should only move 1 line of code and everything will work fine.

Portion newPortion = new Portion();

newPortion.setText(“changed, should be bold”);

Sorry for taking so long time to investigate it carefully.