ipParagraph.getPortions() divide a same word into two

Hi,

I’m using IParagraph getPortions() to get each words in a slide. But it divide a same word in to two in some occasions. Here is the code I’m using

ITextFrame[] tb = SlideUtil.getAllTextFrames(presentation, true);
for (int i = 0; i < tb.length; i++)
			for (IParagraph ipParagraph : tb[i].getParagraphs())
				for (IPortion iPortion : ipParagraph.getPortions()) {

					iPortion.getPortionFormat().setLatinFont(fd1);
					strToFind = iPortion.getText().toLowerCase();
}

In some occations iPortion is getting only a part of the word. What is the reason for that and how can I prevent that.

Thanks in advance.

@ravindueranga,

I have observed your following comments:

Actually, this is not an issue but internal implementation of text frame holding text. Every text frame has got collection of paragraphs. The paragraphs are formed on the basis of new line feeds, new bullets or carriage return in text. Inside every paragraph there is collection of portions. The same text that is available in paragraphs is internally divided in collection of portions based on change in font properties like color, font, height, italic, bold etc. In short, the portion maintains the formatting of text inside paragraph. If you extract text on paragraph level, you will get all text in a paragraph inside single string. Moreover, if you extract the text on TextFrame level, you will get entire text inside shape in one go. I hope this will be understandable now.

Many Thanks,

Mudassir Fayyaz

If its possible can you please give an example? How should I change this current code?

@ravindueranga,

Please try using following sample code on your end.

public static void extractText()
{
 ITextFrame[] tb = SlideUtil.getAllTextFrames(presentation, true);
for (int i = 0; i < tb.length; i++)
                        for (IParagraph ipParagraph : tb[i].getParagraphs())
                        {
                            strToFind = ipParagraph.getText().toLowerCase();
                                /*for (IPortion iPortion : ipParagraph.getPortions()) {

                                        iPortion.getPortionFormat().setLatinFont(fd1);
                                        strToFind = iPortion.getText().toLowerCase();
                                 }*/
                        }   
}

Many Thanks,

Mudassir Fayyaz

But I need to use following part too. How can I use that on ipParagraph?

iPortion.getPortionFormat().setLatinFont(fd1);

fd1 is as follows,

FontData fd1 = new FontData(documentFont);

@ravindueranga,

If you need to access font properties, they are set on portion level. Please also note that if a paragraph has text in single formatting, it will have all text in one portion. You will get different portion whenever there will be a change in text formatting. I hope this will be understandable.

Many Thanks,

Mudassir Fayyaz