HeaderFooter Class |
Namespace: Aspose.Words
The HeaderFooter type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | HeaderFooter |
Creates a new header or footer of the specified type.
|
Name | Description | |
---|---|---|
![]() ![]() | ChildNodes |
Gets all immediate child nodes of this node.
(Inherited from CompositeNode.) |
![]() ![]() | Count |
Gets the number of immediate children of this node.
(Inherited from CompositeNode.) |
![]() ![]() | Document |
Gets the document to which this node belongs.
(Inherited from Node.) |
![]() ![]() | FirstChild |
Gets the first child of the node.
(Inherited from CompositeNode.) |
![]() ![]() | FirstParagraph |
Gets the first paragraph in the story.
(Inherited from Story.) |
![]() ![]() | HasChildNodes |
Returns true if this node has any child nodes.
(Inherited from CompositeNode.) |
![]() ![]() | HeaderFooterType |
Gets the type of this header/footer.
|
![]() ![]() | IsComposite |
Returns true as this node can have child nodes.
(Inherited from CompositeNode.) |
![]() ![]() | IsHeader |
True if this HeaderFooter object is a header.
|
![]() ![]() | IsLinkedToPrevious |
True if this header or footer is linked to the corresponding header or footer
in the previous section.
|
![]() ![]() | LastChild |
Gets the last child of the node.
(Inherited from CompositeNode.) |
![]() ![]() | LastParagraph |
Gets the last paragraph in the story.
(Inherited from Story.) |
![]() ![]() | NextSibling |
Gets the node immediately following this node.
(Inherited from Node.) |
![]() ![]() | NodeType |
Returns NodeType.HeaderFooter.
(Overrides NodeNodeType.) |
![]() ![]() | Paragraphs |
Gets a collection of paragraphs that are immediate children of the story.
(Inherited from Story.) |
![]() ![]() | ParentNode |
Gets the immediate parent of this node.
(Inherited from Node.) |
![]() ![]() | ParentSection |
Gets the parent section of this story.
|
![]() ![]() | PreviousSibling |
Gets the node immediately preceding this node.
(Inherited from Node.) |
![]() ![]() | Range |
Returns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node.) |
![]() ![]() | StoryType |
Gets the type of this story.
(Inherited from Story.) |
![]() ![]() | Tables |
Gets a collection of tables that are immediate children of the story.
(Inherited from Story.) |
Name | Description | |
---|---|---|
![]() ![]() | Accept |
Accepts a visitor.
(Overrides NodeAccept(DocumentVisitor).) |
![]() ![]() | AppendChild |
Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode.) |
![]() ![]() | AppendParagraph |
A shortcut method that creates a Paragraph object with optional text and appends it to the end of this object.
(Inherited from Story.) |
![]() ![]() | Clone | (Inherited from Node.) |
![]() ![]() | DeleteShapes |
Deletes all shapes from the text of this story.
(Inherited from Story.) |
![]() | Equals | (Inherited from Object.) |
![]() ![]() | GetAncestor(Type) |
Gets the first ancestor of the specified object type.
(Inherited from Node.) |
![]() ![]() | GetAncestor(NodeType) |
Gets the first ancestor of the specified NodeType.
(Inherited from Node.) |
![]() ![]() | GetChild |
Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode.) |
![]() ![]() | GetChildNodes |
Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode.) |
![]() ![]() | GetEnumerator |
Provides support for the for each style iteration over the child nodes of this node.
(Inherited from CompositeNode.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() ![]() | GetText |
Gets the text of this node and of all its children.
(Inherited from CompositeNode.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | IndexOf |
Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode.) |
![]() ![]() | InsertAfter |
Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode.) |
![]() ![]() | InsertBefore |
Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode.) |
![]() ![]() | NextPreOrder |
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() | PrependChild |
Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode.) |
![]() ![]() | PreviousPreOrder |
Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() | Remove |
Removes itself from the parent.
(Inherited from Node.) |
![]() ![]() | RemoveAllChildren |
Removes all the child nodes of the current node.
(Inherited from CompositeNode.) |
![]() ![]() | RemoveChild |
Removes the specified child node.
(Inherited from CompositeNode.) |
![]() ![]() | RemoveSmartTags |
Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode.) |
![]() ![]() | SelectNodes |
Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode.) |
![]() ![]() | SelectSingleNode |
Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode.) |
![]() | ToString | (Inherited from Object.) |
![]() ![]() | ToString(SaveFormat) |
Exports the content of the node into a string in the specified format.
(Inherited from Node.) |
![]() ![]() | ToString(SaveOptions) |
Exports the content of the node into a string using the specified save options.
(Inherited from Node.) |
HeaderFooter can contain Paragraph and Table child nodes.
HeaderFooter is a section-level node and can only be a child of Section. There can only be one HeaderFooter or each HeaderFooterType in a Section.
If Section does not have a HeaderFooter of a specific type or the HeaderFooter has no child nodes, this header/footer is considered linked to the header/footer of the same type of the previous section in Microsoft Word.
When HeaderFooter contains at least one Paragraph, it is no longer considered linked to previous in Microsoft Word.
// Open the template document, containing obsolete copyright information in the footer Document doc = new Document(MyDir + "Footer.docx"); HeaderFooterCollection headersFooters = doc.FirstSection.HeadersFooters; HeaderFooter footer = headersFooters[HeaderFooterType.FooterPrimary]; FindReplaceOptions options = new FindReplaceOptions { MatchCase = false, FindWholeWordsOnly = false }; int currentYear = System.DateTime.Now.Year; footer.Range.Replace("(C) 2006 Aspose Pty Ltd.", $"Copyright (C) {currentYear} by Aspose Pty Ltd.", options); doc.Save(ArtifactsDir + "HeaderFooter.ReplaceText.doc");
Document doc = new Document(MyDir + "Header and footer types.docx"); foreach (Section section in doc.OfType<Section>()) { // 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 = section.HeadersFooters[HeaderFooterType.FooterFirst]; footer?.Remove(); // Primary footer is the footer used for odd pages footer = section.HeadersFooters[HeaderFooterType.FooterPrimary]; footer?.Remove(); footer = section.HeadersFooters[HeaderFooterType.FooterEven]; footer?.Remove(); } doc.Save(ArtifactsDir + "HeaderFooter.RemoveFooters.docx");
Document doc = new Document(); HeaderFooter header = new HeaderFooter(doc, HeaderFooterType.HeaderPrimary); doc.FirstSection.HeadersFooters.Add(header); // Add a paragraph with text to the footer Paragraph para = header.AppendParagraph("My header"); Assert.True(header.IsHeader); Assert.True(para.IsEndOfHeaderFooter); HeaderFooter footer = new HeaderFooter(doc, HeaderFooterType.FooterPrimary); doc.FirstSection.HeadersFooters.Add(footer); // Add a paragraph with text to the footer para = footer.AppendParagraph("My footer"); Assert.False(footer.IsHeader); Assert.True(para.IsEndOfHeaderFooter); Assert.AreEqual(footer, para.ParentStory); Assert.AreEqual(footer.ParentSection, para.ParentSection); Assert.AreEqual(footer.ParentSection, header.ParentSection); doc.Save(ArtifactsDir + "HeaderFooter.HeaderFooterCreate.docx");