翻譯|使用教程|編輯:李顯亮|2021-04-14 10:10:57.603|閱讀 224 次
概述:本文向您展示如何使用Spire.Doc for Java在Word文檔中添加尾注。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Spire.Doc for Java 是一款專業的Java Word組件,開發人員使用它可以輕松地將Word文檔創建、讀取、編輯、轉換和打印等功能集成到自己的Java應用程序中。
本文向您展示如何使用Spire.Doc for Java在Word文檔中添加尾注。可點擊此處下載最新版測試。
import com.spire.doc.*; import com.spire.doc.documents.Paragraph; import com.spire.doc.fields.Footnote; import com.spire.doc.fields.TextRange; import java.awt.*; public class AddEndnote { public static void main(String[] args) { //Create a Document object Document doc = new Document(); //Load the sample Word file doc.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.docx"); //Get the first section Section section = doc.getSections().get(0); //Get the specific paragraph to add endnote Paragraph paragraph = section.getParagraphs().get(2); //Add an endnote Footnote endnote = paragraph.appendFootnote(FootnoteType.Endnote); //Set endnote text TextRange textRange = endnote.getTextBody().addParagraph().appendText("This is an endnote created by Spire.Doc."); //Set text format of endnote textRange.getCharacterFormat().setFontName("Arial"); textRange.getCharacterFormat().setFontSize(13f); textRange.getCharacterFormat().setTextColor(Color.RED); //Save to file doc.saveToFile("AddEndnote.docx", FileFormat.Docx_2013); } }
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn