Fußnote Eine Art von Kommentar, der den Inhalt eines Wortes oder Satzes beschreibt. Oft am Ende einer Seite platziert. Die Fußnote ermöglicht es dem Benutzer, einige komplexe Wörter klarer zu lernen und die Vollständigkeit zu bewahren. Daher verwendet diese Spezifikation Spire.Doc, um Word-Dokumenten für Java-Anwendungen Fußnoten hinzuzufügen. Die Methode wird beschrieben.
import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.*;
import java.awt.*;
public class WordFootnote {
    public static void main(String[] args) throws Exception {
        //Beispieldokument laden
        Document doc = new Document();
        doc.loadFromFile("Sample.docx", FileFormat.Docx_2010);
        //Holen Sie sich die erste Stufe der ersten Auswahl.
        Paragraph para = doc.getSections().get(0).getParagraphs().get(0);
        //Fügen Sie nach dem ersten Absatz eine Fußnote hinzu
        Footnote footnote = para.appendFootnote(FootnoteType.Footnote);
        //Fügen Sie Fußnoteninhalt hinzu und formatieren Sie die Schriftart
        TextRange text = footnote.getTextBody().addParagraph().appendText("Demo of Spire.Doc");
        text.getCharacterFormat().setFontName("Arial Black");
        text.getCharacterFormat().setFontSize(10);
        text.getCharacterFormat().setTextColor(new Color(255, 140, 0));
        footnote.getMarkerCharacterFormat().setFontName("Calibri");
        footnote.getMarkerCharacterFormat().setFontSize(12);
        footnote.getMarkerCharacterFormat().setBold(true);
        footnote.getMarkerCharacterFormat().setTextColor(new Color(0, 0, 139));
        //Dokument speichern
        doc.saveToFile("output/Addfootnote.docx", FileFormat.Docx_2010);
        }
    }
Effekt-Diagramm:

Suchen Sie nach dem angegebenen Text Spire.Doc und fügen Sie eine Fußnote hinzu:
import com.spire.doc.*;
import com.spire.doc.documents.*;
import com.spire.doc.fields.*;
import java.awt.*;
public class WordFootnotes {
    public static void main(String[] args) throws Exception {
        //Beispieldokument laden
        Document doc = new Document();
        doc.loadFromFile("Sample.docx", FileFormat.Docx_2010);
        
        //Suche Text Spire.Doc
        TextSelection[] selections = doc.findAllString("Spire.Doc", false, true);
        for (TextSelection selection : selections) {
            TextRange range = selection.getAsOneRange();
            Paragraph para = range.getOwnerParagraph();
            //Fügt nach dem angegebenen Text eine Fußnote hinzu
            Footnote footnote = para.appendFootnote(FootnoteType.Footnote);
            int index = para.getChildObjects().indexOf(range);
            para.getChildObjects().insert(index + 1, footnote);
            //Fügen Sie Fußnoteninhalt hinzu und formatieren Sie die Schriftart
            TextRange text = footnote.getTextBody().addParagraph().appendText("Demo of Spire.Doc");
            text.getCharacterFormat().setFontName("Arial Black");
            text.getCharacterFormat().setFontSize(10);
            text.getCharacterFormat().setTextColor(new Color(255, 140, 0));
            footnote.getMarkerCharacterFormat().setFontName("Calibri");
            footnote.getMarkerCharacterFormat().setFontSize(12);
            footnote.getMarkerCharacterFormat().setBold(true);
            footnote.getMarkerCharacterFormat().setTextColor(new Color(0, 0, 139));
            //Dokument speichern
            doc.saveToFile("output/Addfootnote.docx", FileFormat.Docx_2010);
        }
    }
}
Effekt-Diagramm:

Recommended Posts