Free Support Forum -

Header Footer Paragraphs


How to check if the current paragraphs is Header/Footers paragraphs or normal body paragraph.
Here is my requirement below:
paragraphs=CurrentSourceDocument.GetChildNodes(NodeType.Paragraph, True).ToArray()

Now paragraphs contains all the paragraphs including Header/Footer paragraphs.
So i need to check if the the current paragraphs is a header/Footer paragraphs.


This message was posted using Page2Forum from DocumentBuilder.MoveToHeaderFooter Method - Aspose.Words for .NET

Hi Timothy,

Thanks for your request. I think, you can simply try to get an ancestor of the paragraph of the specific type. If ancestor of this type is not null then paragraph is a child of this ancestor. For example:


/// Returns tru if the node is inside HeaderFooter.


private bool IsHeaderFooterChild(Node node)


return node.GetAncestor(NodeType.HeaderFooter) != null;


Hope this helps.

Best regards,