使用Apache POI将注释添加到Powerpoint幻灯片

问题描述:

是否可以使用Apache POI以编程方式创建的PowerPoint幻灯片添加注释?使用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(); 

...返回null。

是否有另一种方法来创建必要的笔记对象,也许使用我没有找到的工厂类?

或者,有没有另一种方式来添加笔记到不涉及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 
    [...] 
+0

这是行得通的。谢谢! – GBP 2016-09-26 11:31:38

在最新版本中不支持添加PowerPoint笔记。

+1

它可能不会太难,虽然添加的功能,如果有人有兴趣自愿做的工作!所有的记录支持都存在,它只需要在用户模型代码 – Gagravarr 2012-04-26 16:55:46

+0

中以正确的顺序进行接线。我没有太多时间,但是可能奖励会是一个很好的激励。 – eabraham 2012-04-26 20:31:31

+0

这个答案已经过时 – 2018-01-18 08:37:43