java - 使用 Apache POI 向 Powerpoint 幻灯片添加注释

标签 java apache-poi

是否可以向使用 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/

相关文章:

java - 通过 XSSFRichTexString 和 Jsoup 格式化 Apache POI Excel 文本

java - 有什么方法可以使用 Apache POI 在 Excel 中创建数据透视表吗?

java - 找不到com.intellij.lang.properties.charset.Native2AsciiCharsetProvider

java错误: cannot find symbol EqualsUtil. areEqual

excel - 如何将 apache poi 工作簿转换为 Spark 数据框?

java - 如何解决java.io.IOException : Read error when reading Excel file using apache POI

java - apache poi从非常大的xls复制到新的工作簿表

java - 在 Java 中实现启用/禁用方法的最佳方法是什么?

java - 无法连接到 PostgreSQLContainer : java. io.EOFException

java - elasticsearch:找不到索引数据(单元节点已关闭)