Hi All,
I have done word document comparison tool (windows application) using ASP.NET. I have used Microsoft word object library to read word document. It is working fine. When I started to do the project client wanted to compare documents text only I mean need not to compare formats, Header and footer. So I easily did that using document.text property. Now client wants to compare even header and footers. I am unable to read header and footer in sequential manner. Anybody could help me in this regard.
Note.
I want to read document in following manner
- Read Header if document contain header
- Read paragraph contain text
- Read Footer
Each page have to be read in above mentioned manner.
I can easily read Header, footer and document contains text alone. As I need to compare source document and destination document line by line and expose mismatched record in report format, I need to read the word document line by line. Please help me
Thanks and Regards
Ramadurai Jayaraman

Candy Brown24 reputationPosted Dec 10, 2014, 11:38 PM EST
Nevertheless try the following:
var doc = DocumentModel.Load("Sample.docx"); foreach (var section in doc.Sections) { HeaderFooter headerFooter; Liststring> texts; // Read first page header's text. headerFooter = section.HeadersFooters[HeaderFooterType.HeaderFirst]; if (headerFooter != null) texts.Add(headerFooter.Content.ToString()); // Read even pages header's text. headerFooter = section.HeadersFooters[HeaderFooterType.HeaderEven]; if (headerFooter != null) texts.Add(headerFooter.Content.ToString()); // Read default header's text. headerFooter = section.HeadersFooters[HeaderFooterType.HeaderDefault]; if (headerFooter != null) texts.Add(headerFooter.Content.ToString()); // Read section's text. texts.Add(section.Content.ToString()); // Read first page footer's text. headerFooter = section.HeadersFooters[HeaderFooterType.FooterFirst]; if (headerFooter != null) texts.Add(headerFooter.Content.ToString()); // Read even pages footer's text. headerFooter = section.HeadersFooters[HeaderFooterType.FooterEven]; if (headerFooter != null) texts.Add(headerFooter.Content.ToString()); // Read default footer's text. headerFooter = section.HeadersFooters[HeaderFooterType.FooterDefault]; if (headerFooter != null) texts.Add(headerFooter.Content.ToString()); }