Hi Vinay,
Thanks for your inquiry. It is hard to meaningfully output headers and footers to plain text because it is not paginated. Aspose.Words exports only primary headers and footers at the beginning and end of each section. You can disable export of headers and footers altogether by setting TxtSaveOptions.ExportHeadersFooters property to false.
In your document, the header/footer are of type HeaderFirst and FooterFirst. Please use the following code example to copy the contents of HeaderFirst and FooterFirst into HeaderPrimary and FooterPrimary. In this case, you will get the header/footer in output text file. Hope this helps you. Please let us know if you have any more queries.
public static void CopyHeaderFooter(Section section, HeaderFooterType source, HeaderFooterType dest)
{
NodeCollection hfNodes = section.HeadersFooters[source].ChildNodes;
HeaderFooter headerfooter;
if (section.HeadersFooters[dest] == null)
{
headerfooter = new HeaderFooter(section.Document,
dest);
section.HeadersFooters.Add(headerfooter);
}
section.HeadersFooters[dest].ChildNodes.Clear();
foreach (Node node in hfNodes)
section.HeadersFooters[dest].ChildNodes.Add(node.Clone(true));
Document doc = new Document(MyDir + "My_Doc.doc");
CopyHeaderFooter(doc.FirstSection,
HeaderFooterType.HeaderFirst, HeaderFooterType.HeaderPrimary);
CopyHeaderFooter(doc.FirstSection,
HeaderFooterType.FooterFirst, HeaderFooterType.FooterPrimary);
doc.Save(MyDir + "Out.txt", SaveFormat.Text);
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:8.0pt;
mso-para-margin-left:0in;
line-height:107%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
<![endif]–>