close messageThis website uses 'cookies', both our own as well as from third parties, to provide a better experience and service. When browsing our website or using our services you agree to our use of 'cookies'. For more information, see our Privacy policy.

addFootnote

addFootnote

BASIC / ADVANCED / PREMIUM

Inserts a footnote into the Word document.

Description
public void addFootnote(OptionsFootnote options) throws Exception

This method allows the insertion of a footnote into the Word document.

Parameters

options

Option Type Description
textDocument String Text that will appear in the Word document.
textFootnote WordFragment WordFragment that will appear as the footnote in the Word document.
footnoteMark HashMap<String, String>
  • customMark: a special character, if any, that you would like to use for the call to the footnote content.
  • font: the font family you wish to use (Arial, Calibri...).
  • bold: bold text.
  • bidi: bidi option.
  • italic: turn on italics.
  • color: an hexadecimal color ("000000", "FF0000"...).
  • rtl: right to left language.
  • highlightColor: black, blue, cyan, green, magenta, red, yellow, white, darkBlue, darkCyan, darkGreen, darkMagenta, darkRed, darkYellow, darkGray, lightGray, none.
  • underline: underlines text: single.
  • backgroundColor: an hexadecimal color.
referenceMark HashMap<String, String>
  • font: the font family you wish to use (Arial, Calibri...).
  • bold: bold text.
  • bidi: bidi option.
  • italic: turn on italics.
  • color: an hexadecimal color ('000000', 'FF0000'...).
  • rtl: right to left language.
Code samples

Example #1

x
 
1
package examples.Core.addFootnote;
2
3
import java.util.ArrayList;
4
import java.util.HashMap;
5
6
import com.javadocx.CreateDocx;
7
import com.javadocx.WordFragment;
8
import com.javadocx.elements.*;
9
10
public class Sample1 {
11
    public static void main(String[] args) throws Exception {
12
        CreateDocx docx = new CreateDocx();
13
14
        OptionsText textFootnote = new OptionsText();
15
        textFootnote.setText("The footnote we want to insert.");
16
        WordFragment textFootnoteFragment = new WordFragment(docx, "footnote");
17
        textFootnoteFragment.addText(textFootnote);
18
19
        OptionsImage imageOptions = new OptionsImage();
20
        imageOptions.setImageAlign("center")
21
                    .setScaling(50)
22
                    .setTextWrap(0);
23
24
        textFootnoteFragment.addImage("src/examples/files/img/image.png", imageOptions);
25
26
        HashMap<String, String> footnoteMarkOptions = new HashMap<String, String>();
27
        footnoteMarkOptions.put("customMark", "*");
28
29
        OptionsFootnote footnoteOptions = new OptionsFootnote();
30
        footnoteOptions.setTextDocument("footnote")
31
                       .setTextFootnote(textFootnoteFragment)
32
                       .setFootnoteMark(footnoteMarkOptions);
33
34
        WordFragment footnoteFragment = new WordFragment(docx);
35
        footnoteFragment.addFootnote(footnoteOptions);
36
37
        OptionsText textOptionsA = new OptionsText();
38
        textOptionsA.setText("Here comes the ");
39
        WordFragment textFragmentA = new WordFragment(docx);
40
        textFragmentA.addText(textOptionsA);
41
42
        OptionsText textOptionsB = new OptionsText();
43
        textOptionsB.setText(" and some other text.");
44
        WordFragment textFragmentB = new WordFragment(docx);
45
        textFragmentB.addText(textOptionsB);
46
47
        ArrayList<WordFragment> text = new ArrayList<WordFragment>();
48
        text.add(textFragmentA);
49
        text.add(footnoteFragment);
50
        text.add(textFragmentB);
51
52
        docx.addText(text);
53
54
        docx.addText("Some other text.");
55
56
        docx.createDocx("example_addFootnote_1");
57
    }
58
}
59

The resulting Word document looks like:

­
­