Hello, I am using Aspose Slides in Java. I’ve written the below function to convert all non-table elements of the input pptx file to a given font size. However, when I view the output file, the font size has been changed but it’s often erratic. If I set FONT_SIZE to 10, some of the text is size 9.7, some is 11, some is 8, etc. To be clear, it HAS been changed, but not to the target font height. How can I resolve this and make the font height consistent? Thank you. Code:
public ISlide[] changeFontSize(ISlide[] slides) {
for(ISlide slide: slides) {
IShapeCollection slideContents = slide.getShapes();
for(int i = 0; i < slideContents.size(); i++) {
int port = 0;
while(!((Object)slide.getShapes().get_Item(port).getClass().getSimpleName()).toString().equals("AutoShape")) {
port++;
}
if(((Object)slideContents.get_Item(port).getClass().getSimpleName()).toString().equals("AutoShape")) {
ITextFrame tf = ((IAutoShape) slideContents.get_Item(port)).getTextFrame();
IParagraphCollection textFrameContents = tf.getParagraphs();
for (int j = 0; j < textFrameContents.getCount(); j++) {
IParagraph pg = textFrameContents.get_Item(j);
IPortionCollection paragraphContents = pg.getPortions();
for (int k = 0; k < paragraphContents.getCount(); k++) {
IPortion portion = paragraphContents.get_Item(k);
portion.getPortionFormat().setFontHeight(FONT_SIZE);
}
}
}
}
}
return slides;
}