The issue I reported above is fixed with the latest Aspose.Slides (16.2.0). But that was just one slide I extracted from an presentation. For the rest of slides, the issue still persists. Please check the attached presentation from the slide #3 and so on.
public void test() throws Exception {
String presentationPath = “Praesentation_bayHochschulen_BayBIDS_komprimiert96ppi.pptx”;
InputStream inputStream = new FileInputStream(presentationPath);
Presentation presentation = new Presentation(inputStream);
inputStream.close();
// Slide #2
ISlide slide = presentation.getSlides().get_Item(1);
IShapeCollection shapes = slide.getShapes();
IAutoShape shape = (IAutoShape) shapes.get_Item(1);
IParagraphCollection paragraphs = shape.getTextFrame().getParagraphs();
for (IParagraph paragraph : paragraphs) {
translateParagraph(paragraph);
}
// Slide #3
slide = presentation.getSlides().get_Item(2);
shapes = slide.getShapes();
shape = (IAutoShape) shapes.get_Item(0);
paragraphs = shape.getTextFrame().getParagraphs();
for (IParagraph paragraph : paragraphs) {
translateParagraph(paragraph);
}
// Slide #4
slide = presentation.getSlides().get_Item(3);
shapes = slide.getShapes();
shape = (IAutoShape) shapes.get_Item(1);
paragraphs = shape.getTextFrame().getParagraphs();
for (IParagraph paragraph : paragraphs) {
translateParagraph(paragraph);
}
// Slide #5
slide = presentation.getSlides().get_Item(4);
shapes = slide.getShapes();
shape = (IAutoShape) shapes.get_Item(1);
paragraphs = shape.getTextFrame().getParagraphs();
for (IParagraph paragraph : paragraphs) {
translateParagraph(paragraph);
}
// Slide #6
slide = presentation.getSlides().get_Item(5);
shapes = slide.getShapes();
shape = (IAutoShape) shapes.get_Item(1);
paragraphs = shape.getTextFrame().getParagraphs();
for (IParagraph paragraph : paragraphs) {
translateParagraph(paragraph);
}
presentation
.save(“Praesentation_bayHochschulen_BayBIDS_komprimiert96ppi-aspose.pptx”,
SaveFormat.Pptx);
}
public void translateParagraph(IParagraph paragraph) {
if (paragraph.getText().trim().isEmpty()) {
return;
}
IPortion portion = paragraph.getPortions().get_Item(0);
IPortionFormatEffectiveData effectiveData = portion
.createPortionFormatEffective();
float fontHeight = effectiveData.getFontHeight();
boolean bold = effectiveData.getFontBold();
boolean italic = effectiveData.getFontItalic();
byte underline = effectiveData.getFontUnderline();
IPortion newPortion = new Portion(“T_” + portion.getText());
paragraph.getPortions().removeAt(0);
paragraph.getPortions().insert(0, newPortion);
newPortion.getPortionFormat().setFontHeight(fontHeight);
if (bold) {
newPortion.getPortionFormat().setFontBold(NullableBool.True);
}
if (italic) {
newPortion.getPortionFormat().setFontItalic(NullableBool.True);
}
newPortion.getPortionFormat().setFontUnderline(underline);
}