hi,
I solved it by doing some workaround i m able to extract header, footer and maincontent as html strings
here's the code for that
public void asposeReturnHtmlFromDoc(string docPath, ref string mainContent,
ref string header, ref string footer)
{
//open the document
Document myDoc = new Document(docPath);
Document myDocHeader = new Document(docPath);
Document myDocFooter = new Document(docPath);
try
{
//remove Only Header Footer From the Obj
myDoc.FirstSection.ClearHeadersFooters();
//Remove All the Content
foreach (Section sec in myDocHeader.Sections)
{
sec.Body.RemoveAllChildren();
}
//Remove Footer
foreach (HeaderFooter myFooter in myDocHeader.FirstSection.HeadersFooters)
{
if (myFooter.IsHeader == false)
{
myFooter.RemoveAllChildren();
}
}
//Remove All Content
foreach (Section sec in myDocFooter.Sections)
{
sec.Body.RemoveAllChildren();
}
//Remove Header
foreach (HeaderFooter myHeader in myDocFooter.FirstSection.HeadersFooters)
{
if (myHeader.IsHeader == true)
{
myHeader.RemoveAllChildren();
}
}
//Memory stream To Read The different Section
MemoryStream msOut = new MemoryStream();
MemoryStream msHeadOut = new MemoryStream();
MemoryStream msFooterOut = new MemoryStream();
//read to memorystreams
myDoc.Save(msOut, SaveFormat.Html);
myDocHeader.Save(msHeadOut, SaveFormat.Html);
myDocFooter.Save(msFooterOut, SaveFormat.Html);
//extract html string from streams
Encoding enc = Encoding.UTF8;
mainContent = enc.GetString(msOut.GetBuffer());
header = enc.GetString(msHeadOut.GetBuffer());
footer = enc.GetString(msFooterOut.GetBuffer());
}
catch (Exception ex)
{
}
finally
{
myDoc = null;
myDocFooter = null;
myDocHeader = null;
GC.Collect();
}
}