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.

addPageBorders

addPageBorders

BASIC / ADVANCED / PREMIUM

Adds custom page borders to the current Word document.

Description
public void addPageBorders(OptionsPageBorders options)

This method allows you to insert page borders into the Word document.

Parameters

options

Option Type Description
display String
  • allPages (display page border on all pages: default value).
  • firstPage (display page border on first page).
  • notFirstPage (display page border on all pages except first).
borderColor String Hexadecimal color ("000000" (default), "FF0000" ...).
borderSpace Integer Border spacing in points (default is 24).
borderStyle String It can be none, single (default), double ... See, for example, http://www.schemacentral.com/sc/ooxml/t-w_ST_Border.html for a complete list of border available styles.
borderWidth Integer Page border width in eigths of a point (default value is 4).
border<Side>Color String Hexadecimal color ("000000" (default), "FF0000" ...). <side> stands for top, right, left or bottom.
border<Side>Spacing Integer Border spacing in points (default is 24). <side> stands for top, right, left or bottom.
border<Side>Style String It can be none, single (default), double ... See, for example, http://www.schemacentral.com/sc/ooxml/t-w_ST_Border.html for a complete list of border available styles <side> stands for top, right, left or bottom.
border<Side>Width String Page border width in eigths of a point (default value is 4). <side> stands for top, right, left or bottom.
offsetFrom String Possible values are: "page" or "text".
zOrder Integer Sets the z-index of the border.
Code samples

Example #1

x
 
1
package examples.LayoutAndGeneral.addPageBorders;
2
3
import com.javadocx.CreateDocx;
4
import com.javadocx.elements.*;
5
6
public class Sample1 {
7
    public static void main(String[] args) throws Exception {
8
        CreateDocx docx = new CreateDocx();
9
        
10
        OptionsPageBorders pageBordersOptions = new OptionsPageBorders();
11
        pageBordersOptions.setBorderWidth(12)
12
                          .setBorderTopColor("FF0000");
13
        
14
        docx.addPageBorders(pageBordersOptions);
15
        
16
        String text = "This is just a chunk of text that we will repeat couple of times to fill up some space. This is just a chunk of text that we will repeat couple of times to fill up some space.";
17
        
18
        docx.addText(text);
19
        docx.addText("Another chunk of text");
20
        docx.addText(text);
21
        
22
        docx.createDocx("example_addPageBorders_1");
23
    }
24
}      
25

The resulting Word document looks like:

­
­