com.aspose.words

Class TxtExportHeadersFootersMode

  • java.lang.Object
    • com.aspose.words.TxtExportHeadersFootersMode
public class TxtExportHeadersFootersMode 
extends java.lang.Object

Utility class containing constants. Specifies the way headers and footers are exported to plain text format.

Example:

Shows how to specifies the way headers and footers are exported to plain text format.
Document doc = new Document();

// Insert even and primary headers/footers into the document
// The primary header/footers should override the even ones 
doc.getFirstSection().getHeadersFooters().add(new HeaderFooter(doc, HeaderFooterType.HEADER_EVEN));
doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_EVEN).appendParagraph("Even header");
doc.getFirstSection().getHeadersFooters().add(new HeaderFooter(doc, HeaderFooterType.FOOTER_EVEN));
doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_EVEN).appendParagraph("Even footer");
doc.getFirstSection().getHeadersFooters().add(new HeaderFooter(doc, HeaderFooterType.HEADER_PRIMARY));
doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY).appendParagraph("Primary header");
doc.getFirstSection().getHeadersFooters().add(new HeaderFooter(doc, HeaderFooterType.FOOTER_PRIMARY));
doc.getFirstSection().getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY).appendParagraph("Primary footer");

// Insert pages that would display these headers and footers
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Page 1");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.writeln("Page 2");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.write("Page 3");

// Three values are available in TxtExportHeadersFootersMode enum:
// "None" - No headers and footers are exported
// "AllAtEnd" - All headers and footers are placed after all section bodies at the very end of a document
// "PrimaryOnly" - Only primary headers and footers are exported at the beginning and end of each section (default value)
TxtSaveOptions saveOptions = new TxtSaveOptions();
{
    saveOptions.setExportHeadersFootersMode(txtExportHeadersFootersMode);
}

doc.save(getArtifactsDir() + "TxtSaveOptions.ExportHeadersFooters.txt", saveOptions);

Field Summary
static final intNONE = 0
No headers and footers are exported.
static final intPRIMARY_ONLY = 1
Only primary headers and footers are exported at the beginning and end of each section.
static final intALL_AT_END = 2
All headers and footers are placed after all section bodies at the very end of a document.
 

    • Field Detail

      • NONE = 0

        public static final int NONE
        No headers and footers are exported.
      • PRIMARY_ONLY = 1

        public static final int PRIMARY_ONLY
        Only primary headers and footers are exported at the beginning and end of each section.

        It is hard to meaningfully output headers and footers to plain text because it is not paginated.

        When this mode is used, only primary headers and footers are exported at the beginning and end of each section.

      • ALL_AT_END = 2

        public static final int ALL_AT_END
        All headers and footers are placed after all section bodies at the very end of a document. This mode is similar to Word.