Example usage for org.apache.poi.xwpf.usermodel XWPFFootnotes addFootnote

List of usage examples for org.apache.poi.xwpf.usermodel XWPFFootnotes addFootnote

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFFootnotes addFootnote.

Prototype

@Internal
public XWPFFootnote addFootnote(CTFtnEdn note) 

Source Link

Document

Add a CT footnote to the document

Usage

From source file:de.knowwe.include.export.FootnoteExporter.java

License:Open Source License

@Override
public void export(Section<FootnoteType> section, DocumentBuilder manager) throws ExportException {
    // find id for our footnote
    String refNumber = section.get().getFootnoteID(section);
    BigInteger noteId = getFootnoteIDInternal(manager, section.getArticle(), refNumber);

    // create footnote for that id
    CTFtnEdn ctNote = CTFtnEdn.Factory.newInstance();
    ctNote.setId(noteId);//from w w w.j  av  a  2  s.com
    ctNote.setType(STFtnEdn.NORMAL);
    XWPFFootnotes footnotes = manager.getDocument().createFootnotes();
    XWPFFootnote footnote = footnotes.addFootnote(ctNote);

    // add contents to footer
    XWPFParagraph footPara = footnote.addNewParagraph(CTP.Factory.newInstance());
    footPara.setStyle(Style.footnote.getStyleName());
    XWPFRun footRun = footPara.createRun();
    footRun.setSubscript(VerticalAlign.SUPERSCRIPT);
    footRun.setText(String.valueOf(noteId.intValue()));
    footRun = footPara.createRun();
    footRun.setSubscript(VerticalAlign.BASELINE);
    DocumentBuilder contentBuilder = new ListBuilder(manager, footPara, Style.text);
    contentBuilder.export(section.getChildren());
}