Hi,
In the attached presentation, I created new Portion with some text and applied some formatting. I then cleared the old portions from a paragraph and added new portion to it. As a result of that, bold style did not get applied on text. Please see screenshot for your reference.
Here’s the code I use:
String presentationPath = “0804Presentation_Francois_Atger.ppt”;
InputStream inputStream = new FileInputStream(presentationPath);
Presentation presentation = new Presentation(inputStream);
inputStream.close();
ISlide slide = presentation.getSlides().get_Item(0);
IAutoShape shape = (IAutoShape) slide.getShapes().get_Item(1);
IParagraph paragraph = shape.getTextFrame().getParagraphs().get_Item(0);
IPortion portion = paragraph.getPortions().get_Item(0);
IPortionFormatEffectiveData effectiveData = portion
.createPortionFormatEffective();
float fontHeight = effectiveData.getFontHeight();
boolean bold = effectiveData.getFontBold();
Color color = effectiveData.getFillFormat().getSolidFillColor();
int red = color.getRed();
int green = color.getGreen();
int blue = color.getBlue();
int alpha = color.getAlpha();
String fontName = effectiveData.getLatinFont().getFontName();
IPortion newPortion = new Portion(“T_François Atger, Territorial Director”);
IPortionFormat newPortionFormat = newPortion.getPortionFormat();
newPortionFormat.setFontHeight(fontHeight);
newPortionFormat.setLatinFont(new FontData(fontName));
newPortionFormat.setFontBold(bold ? NullableBool.True
: NullableBool.False);
System.out.println("Bold: " + newPortionFormat.getFontBold());
newPortionFormat.getFillFormat().setFillType(FillType.Solid);
newPortionFormat.getFillFormat().getSolidFillColor()
.setColorType(ColorType.RGB);
newPortionFormat.getFillFormat().getSolidFillColor()
.setColor(new Color(red, green, blue, alpha));
paragraph.getPortions().clear();
paragraph.getPortions().add(newPortion);
presentation.save(“0804Presentation_Francois_Atger-aspose.ppt”, SaveFormat.Ppt);
Can you check this?
Thanks,
Zeljko
Thanks,
Zeljko