是否可以向使用 Apache POI 以编程方式创建的 powerpoint 幻灯片添加注释?
这是我目前所拥有的
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);
如您所见,似乎没有办法创建向幻灯片对象添加注释所需的对象。
打电话
Notes notesSheet = slide.getNotesSheet();
...返回空值。
是否有另一种方法来创建必要的注释对象,也许使用我尚未找到的工厂类?
或者,是否有另一种方法可以在不涉及使用 Note 类的情况下向幻灯片添加注释?
最佳答案
这个问题很老了,但我希望这个答案能对某人有所帮助。使用 Apache POI 3.12,以下代码应将一些文本作为注释添加到幻灯片中:
// 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
[...]
关于java - 使用 Apache POI 向 Powerpoint 幻灯片添加注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10336111/