Package org.apache.poi.xwpf.model
Class XWPFHeaderFooterPolicy
- java.lang.Object
-
- org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy
-
public class XWPFHeaderFooterPolicy extends java.lang.Object
A .docx file can have no headers/footers, the same header/footer on each page, odd/even page footers, and optionally also a different header/footer on the first page. This class handles sorting out what there is, and giving you the right headers and footers for the document.
-
-
Field Summary
Fields Modifier and Type Field Description static STHdrFtr.Enum
DEFAULT
static STHdrFtr.Enum
EVEN
static STHdrFtr.Enum
FIRST
-
Constructor Summary
Constructors Constructor Description XWPFHeaderFooterPolicy(XWPFDocument doc)
Figures out the policy for the given document, and creates any header and footer objects as required.XWPFHeaderFooterPolicy(XWPFDocument doc, CTSectPr sectPr)
Figures out the policy for the given document, and creates any header and footer objects as required.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XWPFFooter
createFooter(STHdrFtr.Enum type)
Creates an empty footer of the specified type, containing a single empty paragraph, to which you can then set text, add more paragraphs etc.XWPFFooter
createFooter(STHdrFtr.Enum type, XWPFParagraph[] pars)
Creates a new footer of the specified type, to which the supplied (and previously unattached!) paragraphs are added to.XWPFHeader
createHeader(STHdrFtr.Enum type)
Creates an empty header of the specified type, containing a single empty paragraph, to which you can then set text, add more paragraphs etc.XWPFHeader
createHeader(STHdrFtr.Enum type, XWPFParagraph[] pars)
Creates a new header of the specified type, to which the supplied (and previously unattached!) paragraphs are added to.void
createWatermark(java.lang.String text)
XWPFFooter
getDefaultFooter()
XWPFHeader
getDefaultHeader()
XWPFFooter
getEvenPageFooter()
XWPFHeader
getEvenPageHeader()
XWPFFooter
getFirstPageFooter()
XWPFHeader
getFirstPageHeader()
XWPFFooter
getFooter(int pageNumber)
Get the footer that applies to the given (1 based) page.XWPFFooter
getFooter(STHdrFtr.Enum type)
Get this section footer for the given typeXWPFHeader
getHeader(int pageNumber)
Get the header that applies to the given (1 based) page.XWPFHeader
getHeader(STHdrFtr.Enum type)
Get this section header for the given typeXWPFFooter
getOddPageFooter()
Returns the odd page footer.XWPFHeader
getOddPageHeader()
Returns the odd page header.
-
-
-
Field Detail
-
DEFAULT
public static final STHdrFtr.Enum DEFAULT
-
EVEN
public static final STHdrFtr.Enum EVEN
-
FIRST
public static final STHdrFtr.Enum FIRST
-
-
Constructor Detail
-
XWPFHeaderFooterPolicy
public XWPFHeaderFooterPolicy(XWPFDocument doc)
Figures out the policy for the given document, and creates any header and footer objects as required.
-
XWPFHeaderFooterPolicy
public XWPFHeaderFooterPolicy(XWPFDocument doc, CTSectPr sectPr)
Figures out the policy for the given document, and creates any header and footer objects as required.
-
-
Method Detail
-
createHeader
public XWPFHeader createHeader(STHdrFtr.Enum type)
Creates an empty header of the specified type, containing a single empty paragraph, to which you can then set text, add more paragraphs etc.
-
createHeader
public XWPFHeader createHeader(STHdrFtr.Enum type, XWPFParagraph[] pars)
Creates a new header of the specified type, to which the supplied (and previously unattached!) paragraphs are added to.
-
createFooter
public XWPFFooter createFooter(STHdrFtr.Enum type)
Creates an empty footer of the specified type, containing a single empty paragraph, to which you can then set text, add more paragraphs etc.
-
createFooter
public XWPFFooter createFooter(STHdrFtr.Enum type, XWPFParagraph[] pars)
Creates a new footer of the specified type, to which the supplied (and previously unattached!) paragraphs are added to.
-
getFirstPageHeader
public XWPFHeader getFirstPageHeader()
-
getFirstPageFooter
public XWPFFooter getFirstPageFooter()
-
getOddPageHeader
public XWPFHeader getOddPageHeader()
Returns the odd page header. This is also the same as the default one...
-
getOddPageFooter
public XWPFFooter getOddPageFooter()
Returns the odd page footer. This is also the same as the default one...
-
getEvenPageHeader
public XWPFHeader getEvenPageHeader()
-
getEvenPageFooter
public XWPFFooter getEvenPageFooter()
-
getDefaultHeader
public XWPFHeader getDefaultHeader()
-
getDefaultFooter
public XWPFFooter getDefaultFooter()
-
getHeader
public XWPFHeader getHeader(int pageNumber)
Get the header that applies to the given (1 based) page.- Parameters:
pageNumber
- The one based page number
-
getHeader
public XWPFHeader getHeader(STHdrFtr.Enum type)
Get this section header for the given type- Parameters:
type
- of header to return- Returns:
XWPFHeader
object
-
getFooter
public XWPFFooter getFooter(int pageNumber)
Get the footer that applies to the given (1 based) page.- Parameters:
pageNumber
- The one based page number
-
getFooter
public XWPFFooter getFooter(STHdrFtr.Enum type)
Get this section footer for the given type- Parameters:
type
- of footer to return- Returns:
XWPFFooter
object
-
createWatermark
public void createWatermark(java.lang.String text)
-
-