Incorrect number of of portions in PPT

Hi,

I have problem with portions in PPT presentation. If open presentation aa.ppt and read portions from first slide you will get 12 portions, but if you save aa.ppt using PowerPoint (aa1.ppt) you will get 16 as number of portions. I used following code:

public class PresentationPortinsTest {

public static void main(String[] args) throws Exception {
Presentation presentation = new Presentation(“d:/test/aa.ppt”); // after execute try aa1.ppt

Slide slide = presentation.getSlideByPosition(1);

Shapes shapes = slide.getShapes();

List portionList = new ArrayList();

iterateShapes(shapes, portionList);

for(int i=0; i<portionList.size(); i++) {
System.out.println(portionList.get(i).getText());
}

System.out.println("Number of portions is " + portionList.size());

}

private static void iterateShapes(Shapes shapes, List portionList) {
if (shapes != null) {
for (int shapeIndex = 0; shapeIndex < shapes.size(); shapeIndex++) {

Shape shape = shapes.get(shapeIndex);

if (shape instanceof GroupShape) {
GroupShape groupShape = (GroupShape) shape;

iterateShapes(groupShape.getShapes(), portionList);

continue;
}

if (shape instanceof TextFrame) {
TextFrame textFrame = (TextFrame) shape;

Paragraphs paragraphs = textFrame.getParagraphs();

iterateParagraphs(paragraphs, portionList);

continue;
}

if (shape.getTextFrame() != null) {
TextFrame textFrame = shape.getTextFrame();

Paragraphs paragraphs = textFrame.getParagraphs();

iterateParagraphs(paragraphs, portionList);
}
}
}
}

private static void iterateParagraphs(Paragraphs paragraphs,
List portionList) {
if (paragraphs == null) {
return;
}

for (int paragraphIndex = 0; paragraphIndex < paragraphs.size(); paragraphIndex++) {
Paragraph paragraph = paragraphs.get(paragraphIndex);

Portions portions = paragraph.getPortions();

for(int portionIndex=0; portionIndex<portions.size(); portionIndex++) {
portionList.add(portions.get(portionIndex));
}

}
}
}

aa.ppt and aa1.ppt are in attachment

Thanks,

Zeljko

1 Like

Hi Zeljko,

Thanks for your interest in Aspose.Slides.

You are absolutely right in your judgement that presentations "aa.ppt" and "aa1.ppt" as attached are showing different number of portions when text from slide number 1 is extracted from these presentations through Aspose.Slides. However, according to my investigation, when either of these presentations is opened in MS PowerPoint and saved without making any change with some different name, the number of portions remain same in the original and destination presentations.

An issue has been found in slide number 1 of presentation "aa1.ppt", which shows two extra portions that are part of the slide number 2. This issue has been reported as 13531 in our Issue Tracking System for investigating this problem. This thread has been linked with the issue so that you can get an automated notification as soon as the issue is resolved.

Once again, thanks for identifying the issue.

Best Regards

Hi,

Thank you for fast response.

Zeljko

Hi,

Can you inform me about progress on this issue?

Thanks,

Zeljko

Hi Zeljko,

Our development team has observed the specified issue in detail and reached to a conclusion that it’s not an issue at all. PowerPoint can merge or split portions when it saves the presentation and is based on its own logic. So, calculating number of portions is useless tasks because even the same presentation saved twice can have different number of portions in the text.

We are sorry for your inconvenience,

Hi,

Thanks for response. But this is not good enough, because my application cannot pull all portions if I does not re-save aa.ppt. This behavior gives wrong number of words in presentation. I must to use few strategies for counting words, so I cannot use your api for this task.

Thanks,

Zeljko

Hi,

Is there any chance to investigate why not all text from first slide is not pulled in trough your api? It is very important to all text is reachable. Try to get all text from first slide of aa.ppt, then get all text form first slide of aa1.ppt and you will see difference.

Thanks,

Zeljko

Hi Zeljko,

I have observed the code snippet provided by you in your previous post and have modified that. The code snippet is able to read all the portions in slide and there is no difference in the text read from slide 1 of both presentations. Please fell free to share, if the problem still persists. Please use the code snippet below.

public class PresentationPortinsTest {

public static void main(String[] args) throws Exception {
Presentation presentation = new Presentation("d:/test/aa.ppt"); // after execute try aa1.ppt

Slide slide = presentation.getSlideByPosition(1);

Shapes shapes = slide.getShapes();

List portionList = new ArrayList();

iterateShapes(shapes, portionList);

for(int i=0; i<portionList.size(); i++) {
System.out.println(portionList.get(i).getText());
}

System.out.println("Number of portions is " + portionList.size());

}

private static void iterateShapes(Shapes shapes, List portionList) {
if (shapes != null) {
for (int shapeIndex = 0; shapeIndex < shapes.size(); shapeIndex++) {

Shape shape = shapes.get(shapeIndex);
String tex=shape.getAlternativeText();
if (shape instanceof GroupShape) {
GroupShape groupShape = (GroupShape) shape;

iterateShapes(groupShape.getShapes(), portionList);

continue;
}

if (shape instanceof TextFrame) {
TextFrame textFrame = (TextFrame) shape;

Paragraphs paragraphs = textFrame.getParagraphs();

iterateParagraphs(paragraphs, portionList);

continue;
}

if (shape instanceof Rectangle) {
Rectangle Rect = (Rectangle) shape;
TextFrame textFrame =Rect.getTextFrame();
Paragraphs paragraphs = textFrame.getParagraphs();

iterateParagraphs(paragraphs, portionList);

continue;
}

if (shape.getTextFrame() != null) {
TextFrame textFrame = shape.getTextFrame();

Paragraphs paragraphs = textFrame.getParagraphs();

iterateParagraphs(paragraphs, portionList);
}
}
}
}

private static void iterateParagraphs(Paragraphs paragraphs,
List portionList) {
if (paragraphs == null) {
return;
}

for (int paragraphIndex = 0; paragraphIndex < paragraphs.size(); paragraphIndex++) {
Paragraph paragraph = paragraphs.get(paragraphIndex);

Portions portions = paragraph.getPortions();

for(int portionIndex=0; portionIndex<portions.size(); portionIndex++) {
portionList.add(portions.get(portionIndex));
}

}
}
}

Thanks and Regards,

Hi,
I am sorry but I must disappoint you. Example you modified is just confirms that Aspose api does not pull in all text from first slide of aa.ppt. Maybe you accidentally re-save aa.ppt on your machine. Try to execute your previous code with test files which I sent you.

Thanks,

Zeljko

Hi Zeljko,

We are extremely sorry for your inconvenience.

You are right, I may have saved the presentation from PowerPoint and that is why, I was able to read all the portions in the slide. In order to further investigate the problem and issue with ID 16140 has been created in our issue tracking system. This thread has also been linked with the issue, so that you may be automatically notified, once the issue is resolved.

Thanks and Regards,