Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JPresentation
>
Tutorial
> Read notes text
The following example shows you how to read slide's notes text.
import com.independentsoft.office.drawing.ITextParagraphContent; import com.independentsoft.office.drawing.TextParagraph; import com.independentsoft.office.drawing.TextRun; import com.independentsoft.office.presentation.CommonSlideData; import com.independentsoft.office.presentation.Presentation; import com.independentsoft.office.presentation.Slide; public class Example { public static void main(String[] args) { try { Presentation presentation = new Presentation("c:\\test\\input.pptx"); for (Slide slide : presentation.getSlides()) { if (slide.getNotesSlide() != null && slide.getNotesSlide().getCommonSlideData() != null) { CommonSlideData data = slide.getNotesSlide().getCommonSlideData(); for (com.independentsoft.office.presentation.drawing.IGroupElement elemente : data.getShapeTree().getElements()) { if (elemente instanceof com.independentsoft.office.presentation.drawing.Shape) { com.independentsoft.office.presentation.drawing.Shape shape = (com.independentsoft.office.presentation.drawing.Shape) elemente; if (shape.getTextBody() != null) { for (TextParagraph paragraph : shape.getTextBody().getParagraphs()) { for (ITextParagraphContent content : paragraph.getContent()) { if (content instanceof TextRun) { TextRun run = (TextRun) content; System.out.println(run.getText()); } } } } } } } } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*