For the text “This is header text” in attached documnet aspose is not giving style as Header.
para.getParagraphFormat().getStyleName() = Normal.
We have checked in header2.xml file of the documnets its , the content is within hdr tag.Japanese law ISDA Credit Support AnnexISDA Credit Support AnnexCSA_JPN_Test_v1-10 March 2022-109107.docx (25.6 KB)
@ashu_agrawal_sirionlabs_com The returned value is correct. If you check style in MS Word you will see exactly the same value:
@alexey.noskov Its not the style that we are after but the identification that the text is part of header or footer section. How can we achieve that?
Even in the xml file of the document, this text is not part of the doc.xml file and is part of header2.xml file.
We want to identify whether a paragraph is part of header or normal body content of the word document.
Even in MS word, this text is shown under header only.
Just fyi, this is header-footer section that we are talking, not a heading style(H1, H2, etc.)
@AdityaSirion @ashu_agrawal_sirionlabs_com If it is required to detect whether some node is in Header/Footer, the node’s ancestor can be used to achieve this. For example see the following code:
HeaderFooter hf = para.GetAncestor(NodeType.HeaderFooter) as HeaderFooter;
if (hf != null)
Console.WriteLine($"Paragraph is inside {hf.HeaderFooterType}");
Please see our documentation to learn more about Aspose.Words Document Object Model:
https://docs.aspose.com/words/net/aspose-words-document-object-model/
Thanks Alexey. We will try this and get back with results.
1 Like