Hi,
I need to extract text from presentation and also I need text format.
When I try to get font name in attached presentation I get wrong font name, You can see on attached .jpg which font see MS Office and which I get throw code. Pay attention on special characters, like line break in first line, I don’t get any font for them. Here is my test:
public void test() {
Presentation pptxPresentation = new Presentation(
“simple-test.ppt”);
// Get an Array of TextFrameEx objects from the first slide
ITextFrame[] textFramesSlideOne = SlideUtil
.getAllTextBoxes(pptxPresentation.getSlides().get_Item(0));
// Loop through the Array of TextFrames
for (int i = 0; i < textFramesSlideOne.length; i++)
// Loop through paragraphs in current TextFrame
for (IParagraph para : textFramesSlideOne[0].getParagraphs())
// Loop through portions in the current Paragraph
for (IPortion port : para.getPortions()) {
System.out.println(getFontName((Portion) port));
}
}
public String getFontName(Portion portion) {
String fontName = “Not Found”;
IPortionFormat portionFormat = portion.getPortionFormat();
if (portionFormat.getLatinFont() != null) {
fontName = portionFormat.getLatinFont().getFontName();
} else {
if (portionFormat.getEastAsianFont() != null) {
fontName = portionFormat.getEastAsianFont().getFontName();
} else {
if (portionFormat.getSymbolFont() != null) {
fontName = portionFormat.getSymbolFont().getFontName();
}
}
}
return fontName;
}
Am I doing something wrong or there is issue in Yours API?
Thanks
Best regards