ExportHeadersFootersMode

Inheritance: java.lang.Object

public class ExportHeadersFootersMode

Specifies how headers and footers are exported to HTML, MHTML or EPUB.

Examples:

Shows how to omit headers/footers when saving a document to HTML.


 Document doc = new Document(getMyDir() + "Header and footer types.docx");

 // This document contains headers and footers. We can access them via the "HeadersFooters" collection.
 Assert.assertEquals("First header", doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_FIRST).getText().trim());

 // Formats such as .html do not split the document into pages, so headers/footers will not function the same way
 // they would when we open the document as a .docx using Microsoft Word.
 // If we convert a document with headers/footers to html, the conversion will assimilate the headers/footers 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.ExportMode.html", saveOptions);

 // Open our saved document and verify that it does not contain the header's text.
 doc = new Document(getArtifactsDir() + "HeaderFooter.ExportMode.html");

 Assert.assertFalse(doc.getRange().getText().contains("First header"));
 

Fields

FieldDescription
FIRST_PAGE_HEADER_FOOTER_PER_SECTIONFirst page header and footer are exported at the beginning and the end of each section.
FIRST_SECTION_HEADER_LAST_SECTION_FOOTERPrimary header of the first section is exported at the beginning of the document and primary footer is at the end.
NONEHeaders and footers are not exported.
PER_SECTIONPrimary headers and footers are exported at the beginning and the end of each section.
length

Methods

MethodDescription
fromName(String exportHeadersFootersModeName)
getName(int exportHeadersFootersMode)
getValues()
toString(int exportHeadersFootersMode)
public static 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 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.

NONE

public static int NONE

Headers and footers are not exported.

PER_SECTION

public static int PER_SECTION

Primary headers and footers are exported at the beginning and the end of each section.

length

public static int length

fromName(String exportHeadersFootersModeName)

public static int fromName(String exportHeadersFootersModeName)

Parameters:

ParameterTypeDescription
exportHeadersFootersModeNamejava.lang.String

Returns: int

getName(int exportHeadersFootersMode)

public static String getName(int exportHeadersFootersMode)

Parameters:

ParameterTypeDescription
exportHeadersFootersModeint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int exportHeadersFootersMode)

public static String toString(int exportHeadersFootersMode)

Parameters:

ParameterTypeDescription
exportHeadersFootersModeint

Returns: java.lang.String