Example usage for org.apache.poi.xwpf.usermodel XWPFFootnote addNewParagraph

List of usage examples for org.apache.poi.xwpf.usermodel XWPFFootnote addNewParagraph

Introduction

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

Prototype

public XWPFParagraph addNewParagraph(CTP paragraph) 

Source Link

Document

Add a new XWPFParagraph to the end of the footnote.

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);/* www.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());
}