Hi,
I have problem with function getSlides(), for most .ppt files returns slide in same order as in file but in attached file returned slides are in all other order...
public void test() {
Presentation presentation = new Presentation(
"PPT.ppt");
Slides slides = presentation.getSlides();
Slide slide = null;
for (int i = 0; i < slides.getCount(); i++) {
slide = slides.get_Item(i);
for (int j = 0; j < slide.getPlaceholders().getCount(); j++) {
TextHolder th = (TextHolder) slide.getPlaceholders()
.get_Item(j);
if (th != null)
for (int k = 0; k < th.getParagraphs().getCount(); k++) {
Paragraph paragraph = th.getParagraphs().get_Item(k);
for (int n = 0; n < paragraph.getPortions().getCount(); n++) {
Portion portion = paragraph.getPortions().get_Item(
n);
System.out.print(portion.getText());
}
System.out.println("");
}
}
}
}
Can You tell me why is that or help me to fix, I need slides in same order as in presentation...
Thanks
Hi,
I have observed the requirement shared by you and like to share that in case of PPT the SlideCollection holds both normal and master slides. Secondly, the slides collection holds the slide in order they are added in presentation. If you re-order the slide in PowerPoint or using Aspose.Slides, the ordering of slide in SlideCollection will remain the same but its position will be updated. I suggest you to please try using the following sample code on your end to serve the purpose in this regard. It will get the correct number and accurate slide position for you. It is in fact the right approach that is to be adopted for PPT case.
public void test() {
Presentation presentation = new Presentation(
“PPT.ppt”);
Slides slides = presentation.getSlides();
Slide slide = null;
for(int i=1;i<=presentation.getSlides.getSlides().getLastSlidePosition();i++)
{
slide = presentation.getSlideByPosition(i);
slide = slides.get_Item(i);
for (int j = 0; j < slide.getPlaceholders().getCount(); j++) {
TextHolder th = (TextHolder) slide.getPlaceholders()
.get_Item(j);
if (th != null)
for (int k = 0; k < th.getParagraphs().getCount(); k++) {
Paragraph paragraph = th.getParagraphs().get_Item(k);
for (int n = 0; n < paragraph.getPortions().getCount(); n++) {
Portion portion = paragraph.getPortions().get_Item(
n);
System.out.print(portion.getText());
}
System.out.println("");
}
}
}
}
Many Thanks,