Independentsoft
Any library, any programming language
Home
Purchase
Support
Company
Contact
JWord
>
Tutorial
> Create endnote
The following example shows you how to create an endnote.
import com.independentsoft.office.word.Paragraph; import com.independentsoft.office.word.Run; import com.independentsoft.office.word.WordDocument; import com.independentsoft.office.word.footnoteEndnote.Endnote; import com.independentsoft.office.word.footnoteEndnote.EndnoteReference; public class Example { public static void main(String[] args) { try { WordDocument doc = new WordDocument(); // Create the endnote content Run endnoteRun = new Run(); endnoteRun.addText("This is the endnote text that appears at the end of the document."); Paragraph endnoteParagraph = new Paragraph(); endnoteParagraph.add(endnoteRun); Endnote endnote = new Endnote(); endnote.add(endnoteParagraph); // Add endnote to document doc.getEndnotes().add(endnote); // Create main document text with endnote reference Run run1 = new Run(); run1.addText("This is the main text with an endnote reference"); Run run2 = new Run(); run2.add(new EndnoteReference(endnote.getId())); Paragraph paragraph = new Paragraph(); paragraph.add(run1); paragraph.add(run2); doc.getBody().add(paragraph); 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*