簡體   English   中英

使用Apache POI向Powerpoint幻燈片添加注釋

[英]Add notes to a Powerpoint slide using 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();

...返回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
    [...]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM