Is it possible to add notes to a powerpoint slide created programatically using Apache POI?
Here's what I have so far
Slide slide = ppt.createSlide();
org.apache.poi.hslf.record.Notes notesRecord = new ???; // <--- No Public constructor
org.apache.poi.hslf.model.Notes noteModel = new org.apache.poi.hslf.model.Notes(notesRecord ); // <--- Only one constructor which takes a org.apache.poi.hslf.record.Notes
// hopefully make some notes
// add the notes to the slide
slide.setNotes(noteModel);
As you can see, there doesn't seem to be a way to create the objects needed to add notes to the slide object.
Calling
Notes notesSheet = slide.getNotesSheet();
...returns null.
Is there another means to create the necessary notes object, perhaps using a factory class that I have not found?
Or, is there another way to add a note to a slide that doesn't involve working with the Note classes?
The question ist quite old but I hope this answer will help someone. Using Apache POI 3.12 the following code should add some text as notes to a slide:
// create a new empty slide show
XMLSlideShow ppt = new XMLSlideShow();
// add first slide
XSLFSlide slide = ppt.createSlide();
// get or create notes
XSLFNotes note = ppt.getNotesSlide(slide);
// insert text
for (XSLFTextShape shape : note.getPlaceholders()) {
if (shape.getTextType() == Placeholder.BODY) {
shape.setText("String");
break;
}
}
// save
[...]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With