com.aspose.words
Class HeaderFooterType

java.lang.Object
    extended by com.aspose.words.HeaderFooterType

public class HeaderFooterType 
extends java.lang.Object

Utility class containing constants. Identifies the type of header or footer found in a Word file. This is a per section header/footer. Do not renumber as the value of the enum used as an index into plcfhdd.

Example:

Deletes all footers from all sections, but leaves headers intact.
Document doc = new Document(getMyDir() + "HeaderFooter.RemoveFooters.doc");

for (Node sectionNode : doc)
{
    Section section = (Section)sectionNode;

    // Up to three different footers are possible in a section (for first, even and odd pages).
    // We check and delete all of them.
    HeaderFooter footer;

    footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_FIRST);
    if (footer != null)
        footer.remove();

    // Primary footer is the footer used for odd pages.
    footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_PRIMARY);
    if (footer != null)
        footer.remove();

    footer = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.FOOTER_EVEN);
    if (footer != null)
        footer.remove();
}

doc.save(getMyDir() + "HeaderFooter.RemoveFooters Out.doc");

Example:

Inserts a watermark image into a document using DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// The best place for the watermark image is in the header or footer so it is shown on every page.
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);

// Insert a floating picture.
BufferedImage image =
        javax.imageio.ImageIO.read(new File(getMyDir() + "Watermark.png"));

Shape shape = builder.insertImage(image);
shape.setWrapType(WrapType.NONE);
shape.setBehindText(true);

shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE);
shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE);

// Calculate image left and top position so it appears in the centre of the page.
shape.setLeft((builder.getPageSetup().getPageWidth() - shape.getWidth()) / 2);
shape.setTop((builder.getPageSetup().getPageHeight() - shape.getHeight()) / 2);

doc.save(getMyDir() + "DocumentBuilder.InsertWatermark Out.doc");

Field Summary
static final intHEADER_EVEN
           Header for even numbered pages.
static final intHEADER_PRIMARY
           Primary header, also used for odd numbered pages.
static final intFOOTER_EVEN
           Footer for even numbered pages.
static final intFOOTER_PRIMARY
           Primary footer, also used for odd numbered pages.
static final intHEADER_FIRST
           Header for the first page of the section.
static final intFOOTER_FIRST
           Footer for the first page of the section.
 

Field Detail

HEADER_EVEN

public static final int HEADER_EVEN
Header for even numbered pages.

HEADER_PRIMARY

public static final int HEADER_PRIMARY
Primary header, also used for odd numbered pages.

FOOTER_EVEN

public static final int FOOTER_EVEN
Footer for even numbered pages.

FOOTER_PRIMARY

public static final int FOOTER_PRIMARY
Primary footer, also used for odd numbered pages.

HEADER_FIRST

public static final int HEADER_FIRST
Header for the first page of the section.

FOOTER_FIRST

public static final int FOOTER_FIRST
Footer for the first page of the section.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.