apache-poiwordprocessingmlapache-poi-4

wordprocessingml footnote number style (superscripts)


I just added a footnote to the word document. but it seems little bit wierd.

Footnote numbers are usually entered as superscripts, but not now.

How can I insert a footnote number as a superscript?

this is my code..

r = p.createRun()
            String footnoteText = "exexexex "
            BigInteger footnoteId  = createFootnote(document, footnoteText)
            r = p.createRun()
            //r.getCTR().addNewRPr().addNewRStyle().setVal("FootnoteReference")
            r.getCTR().addNewFootnoteReference().setId(footnoteId)

Thanks!

footnote number

footnote


Solution

  • https://www.python2.net/questions-332393.htm

    XWPFStyles styles = document.createStyles()
                XWPFStyle style = new XWPFStyle(CTStyle.Factory.newInstance(), styles)
                style.getCTStyle().setType(STStyleType.CHARACTER)
                style.getCTStyle().setStyleId("FootnoteReference")
                style.getCTStyle().addNewRPr().addNewVertAlign().setVal(STVerticalAlignRun.SUPERSCRIPT)
                styles.addStyle(style)