public class ExportHeadersFootersMode
Example:
Document doc = new Document(getMyDir() + "Header and footer types.docx");
// This document contains headers and footers, whose text contents can be looked up like this
Assert.assertEquals("First header", doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_FIRST).getText().trim());
// Formats such as html do not have a pre-defined equivalent for Microsoft Word headers/footers
// If we convert a document with headers and/or footers to html, they will be assimilated into body text
// We can use a SaveOptions object to omit headers/footers while converting to html
HtmlSaveOptions saveOptions =
new HtmlSaveOptions(SaveFormat.HTML);
{
saveOptions.setExportHeadersFootersMode(ExportHeadersFootersMode.NONE);
}
doc.save(getArtifactsDir() + "HeaderFooter.DisableHeadersFooters.html", saveOptions);
// Open our saved document and verify that it does not contain the header's text
doc = new Document(getArtifactsDir() + "HeaderFooter.DisableHeadersFooters.html");
Assert.assertFalse(doc.getRange().getText().contains("First header"));
Field Summary | ||
---|---|---|
static final int | NONE | |
Headers and footers are not exported.
|
||
static final int | PER_SECTION | |
Primary headers and footers are exported at the beginning and the end of each section.
|
||
static final int | FIRST_SECTION_HEADER_LAST_SECTION_FOOTER | |
Primary header of the first section is exported at the beginning of the document and primary footer is at the end.
|
||
static final int | FIRST_PAGE_HEADER_FOOTER_PER_SECTION | |
First page header and footer are exported at the beginning and the end of each section.
|
public static final int NONE
public static final int PER_SECTION
public static final int FIRST_SECTION_HEADER_LAST_SECTION_FOOTER
public static final int FIRST_PAGE_HEADER_FOOTER_PER_SECTION