Package org.apache.poi.xwpf.model
Class XWPFHeaderFooterPolicy
java.lang.Object
org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy
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
FieldsModifier and TypeFieldDescriptionstatic final org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum
static final org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum
static final org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum
-
Constructor Summary
ConstructorsConstructorDescriptionFigures out the policy for the given document, and creates any header and footer objects as required.XWPFHeaderFooterPolicy
(XWPFDocument doc, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr) Figures out the policy for the given document, and creates any header and footer objects as required. -
Method Summary
Modifier and TypeMethodDescriptioncreateFooter
(org.openxmlformats.schemas.wordprocessingml.x2006.main.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
(org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum type, XWPFParagraph[] pars) Creates a new footer of the specified type, to which the supplied (and previously unattached!) paragraphs are added to.createHeader
(org.openxmlformats.schemas.wordprocessingml.x2006.main.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
(org.openxmlformats.schemas.wordprocessingml.x2006.main.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
(String text) getFooter
(int pageNumber) Get the footer that applies to the given (1 based) page.getFooter
(org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum type) Get this section footer for the given typegetHeader
(int pageNumber) Get the header that applies to the given (1 based) page.getHeader
(org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum type) Get this section header for the given typeReturns the odd page footer.Returns the odd page header.
-
Field Details
-
DEFAULT
public static final org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum DEFAULT -
EVEN
public static final org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum EVEN -
FIRST
public static final org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum FIRST
-
-
Constructor Details
-
XWPFHeaderFooterPolicy
Figures out the policy for the given document, and creates any header and footer objects as required. -
XWPFHeaderFooterPolicy
public XWPFHeaderFooterPolicy(XWPFDocument doc, org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSectPr sectPr) Figures out the policy for the given document, and creates any header and footer objects as required.
-
-
Method Details
-
createHeader
public XWPFHeader createHeader(org.openxmlformats.schemas.wordprocessingml.x2006.main.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(org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum type, XWPFParagraph[] pars) Creates a new header of the specified type, to which the supplied (and previously unattached!) paragraphs are added to. -
getFirstPageHeader
-
getOddPageHeader
Returns the odd page header. This is also the same as the default one... -
getEvenPageHeader
-
getDefaultHeader
-
getHeader
Get the header that applies to the given (1 based) page.- Parameters:
pageNumber
- The one based page number
-
getHeader
public XWPFHeader getHeader(org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum type) Get this section header for the given type- Parameters:
type
- of header to return- Returns:
XWPFHeader
object
-
createWatermark
-