Hi. I have a problem with the text in a presentation which is attached. I have an "arrow" character at the end of text line (this is second portion). When I try to add new portion which has only that character and save the presentation, when I open it, I don't have an "arrow" character but something else. Here is my code:
Presentation presentation = new Presentation("d:/Test.ppt");
Slide slide = presentation.getSlides().get_Item(0);
Shape shape = slide.getShapes().get_Item(0);
TextFrame textFrame = shape.getTextFrame();
Paragraphs paragraphs = textFrame.getParagraphs();
Paragraph paragraph = paragraphs.get_Item(0);
Portions portions = paragraph.getPortions();
Portion portion2 = portions.get_Item(1); //second portion
System.out.println(portion2.getText()); //"arrow" character
Portion portion3 = new Portion();
portion3.setText(portion2.getText());
portions.add(portion3);
presentation.write("d:/Test_2.ppt");
How can I deal with that character? What is it? Is it some kind of special character?
Thanks,
Slavko
Hi Slavko,
I have observed the requirement shared by you and like to share that since you are adding a symbol character, you need to add the symbol font index for portion to render the symbol. I have made some modification in your sample code to serve the purpose. It will work for you and please share if I may help you further in this regard.
Presentation presentation = new Presentation(“d:/Aspose Data/Test_Arrow.ppt”);
Slide slide = presentation.getSlides().get_Item(0);
Shape shape = slide.getShapes().get_Item(0);
TextFrame textFrame = shape.getTextFrame();
Paragraphs paragraphs = textFrame.getParagraphs();
Paragraph paragraph = paragraphs.get_Item(0);
Portions portions = paragraph.getPortions();
Portion portion2 = portions.get_Item(1); //second portion
System.out.println(portion2.getText()); //“arrow” character
Portion portion3 = new Portion();
portion3.setSymbolFontIndex(portion2.getSymbolFontIndex());
portion3.setFontHeight(portion2.getFontHeight());
portion3.setText(portion2.getText());
presentation.write(“d:/Aspose Data/Test_2.ppt”);
Many Thanks,
Hi, I have problems with symbols, this is my test:
public void test() {
Presentation presentation = new Presentation(
"/home/emisia/Desktop/Symbol1.ppt");
Slides slides = presentation.getSlides();
Slide slide = slides.get_Item(1);
TextHolder th = (TextHolder) slide.getPlaceholders().get_Item(1);
Paragraph paragraph = th.getParagraphs().get_Item(0);
Iterator portionsIterator = paragraph.getPortions().iterator();
Portion portion = null;
while (portionsIterator.hasNext()) {
portion = portionsIterator.next();
System.out.println(portion.getText());
System.out.println(presentation.getFonts()
.get_Item(portion.getSymbolFontIndex()).getFontName());
}
and I have two questions,
1. Why this test returns me same font name for symbol and text after symbol?
2. How to know is it symbol or regular text in portion?
Thanks
Hi Djordje,
Thanks for your interest in Aspose.Slides.
I have worked with the presentation file shared by you and have been able to observe the issue specified. It seems to be an issue and I have logged a ticket with ID SLIDESJAVA-34121 in our issue tracking system to further investigate and resolve it.
As far as your question regarding knowing whether a text is a symbol or regular. I like to share that Aspose.Slides adds text in UTF-8 and there is no direct method of identifying if text regular or symbol. However, you can devise the approach on your end to tell whether a text is a symbol by verifying its UTF code. If UTF code falls with in range of Alphabets then its regular text otherwise you can term that as symbol.
http://www.utf8-chartable.de/
Convert String to byte array UTF encoding - Java Code Geeks
We are sorry for your inconvenience,