Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JWord
>
Tutorial
> Section footnote
The example shows you how to create and set footnote on a section.
import com.independentsoft.office.word.NumberingFormat; import com.independentsoft.office.word.Paragraph; import com.independentsoft.office.word.Run; import com.independentsoft.office.word.VerticalAlignment; import com.independentsoft.office.word.WordDocument; import com.independentsoft.office.word.footnoteEndnote.Footnote; import com.independentsoft.office.word.footnoteEndnote.FootnoteReference; import com.independentsoft.office.word.sections.PageSize; import com.independentsoft.office.word.sections.Section; public class Example { public static void main(String[] args) { try { WordDocument doc = new WordDocument(); Footnote footnote1 = new Footnote(1); FootnoteReference footnoteReference = new FootnoteReference(1); Run footnoteRun1 = new Run(); footnoteRun1.setVerticalAlignment(VerticalAlignment.SUPERSCRIPT); footnoteRun1.addFootnoteReferenceMark(); Run footnoteRun2 = new Run(); footnoteRun2.addText("Footnote text."); Paragraph footnoteParagraph = new Paragraph(); footnoteParagraph.add(footnoteRun1); footnoteParagraph.add(footnoteRun2); footnote1.getContent().add(footnoteParagraph); Run run1 = new Run(); run1.addText("Hello Word"); Run footnoteReferenceRun = new Run(); footnoteReferenceRun.setVerticalAlignment(VerticalAlignment.SUPERSCRIPT); footnoteReferenceRun.add(footnoteReference); Paragraph paragraph1 = new Paragraph(); paragraph1.add(run1); paragraph1.add(footnoteReferenceRun); doc.getBody().add(paragraph1); doc.getFootnotes().add(footnote1); Section section = new Section(); section.setPageSize(new PageSize(12240, 15840)); //8.5 x 11 in section.getFootnoteProperties().setNumberingFormat(NumberingFormat.DECIMAL); doc.getBody().setSection(section); doc.save("c:\\test\\output.docx", true); } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*