Access slide and portion format

Hi,


I can not access to second slide text and text formats in attached presentation. Here is my test:
public void test1() {
Presentation pres = new Presentation(
“src/test/resources/org/gs4tr/filters3/msoffice/pptx/portion-format-test.pptx”); //$NON-NLS-1$
for (ISlide slide : pres.getSlides()) {
for (IShape shp : slide.getShapes())
if (shp.getPlaceholder() != null) {
// Change the text of each placeholder
for (IParagraph paragraph : ((IAutoShape) shp)
.getTextFrame().getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
if ((portion.getText().length() != 0)) {
System.out.println("PTEXT: "
+ portion.getText());

System.out.println("FontHeight: "
+ portion
.createPortionFormatEffective()
.getFontHeight());
if (portion.getPortionFormat().getLatinFont() != null)
System.out.println("FontNameLatin: "
+ portion.getPortionFormat()
.getLatinFont()
.getFontName());
if (portion.getPortionFormat().getSymbolFont() != null)
System.out.println("FontNameSymbol: "
+ portion.getPortionFormat()
.getLatinFont()
.getFontName());
if (portion.getPortionFormat()
.getEastAsianFont() != null)
System.out.println("FontNameEA: "
+ portion.getPortionFormat()
.getLatinFont()
.getFontName());

if (portion.createPortionFormatEffective()
.getFontBold()) {
System.out
.println("Bold: " + “Yes messgae”);
} else {
System.out.println("Bold: " + “No message”);
}
if (portion.createPortionFormatEffective()
.getFontItalic()) {
System.out.println("Italic: "
+ “Yes message”);
} else {
System.out.println("Italic: "
+ “No message”);
}
if (portion.createPortionFormatEffective()
.isHardUnderlineLine()) {
System.out.println("Underline: "
+ “Yes message”);
} else {
System.out.println(“Underline: "
+ “No message”);
}
System.out
.println(“Color: "
+ portion
.createPortionFormatEffective()
.getFillFormat()
.getSolidFillColor()
.toString());

System.out.println(”++++++++++++++++++++++++”);
}
}
}

}
}
}


Can You help me?

Thanks
Best regards

Hi,


I have observed your requirements and worked with the sample code shared by you. I have made necessary changes. Please try using following sample code on your end to serve the purpose.

Presentation pres = new Presentation(“D://portion-format-test.pptx”);
for (ISlide slide : pres.getSlides()) {
for (IShape shp : slide.getShapes())
for (IParagraph paragraph : ((IAutoShape) shp)
.getTextFrame().getParagraphs()) {
for (IPortion portion : paragraph.getPortions()) {
if ((portion.getText().length()!=0)){
System.out.println("PTEXT: " + portion.getText());
System.out.println("FontHeight: "+ portion.createPortionFormatEffective().getFontHeight());
if (portion.getPortionFormat().getLatinFont() != null)
System.out.println("FontNameLatin: "+ portion.getPortionFormat().getLatinFont().getFontName());
// System.out.println("FontNameLatin: "+ portion.getPortionFormat().getLatinFont().getFontName());
if (portion.createPortionFormatEffective().getFontBold()){
System.out.println("Bold: "+ “Yes messgae”);
}
else
{
System.out.println("Bold: "+ “No message”);
}
if (portion.createPortionFormatEffective().getFontItalic()){
System.out.println("Italic: "+ “Yes message”);
}
else
{
System.out.println("Italic: "+ “No message”);
}
if (portion.createPortionFormatEffective().isHardUnderlineLine()){
System.out.println("Underline: "+ “Yes message”);
}
else
{
System.out.println("Underline: "+ “No message”);
}
System.out.println(“Color: “+ portion.createPortionFormatEffective().getFillFormat().getSolidFillColor().toString());

System.out.println(”++++++++++++++++++++++++”);
}
}
}

}
}

I hope this will be helpful. Please share if I may help you further in this regard.

Best Regards,