Free Support Forum - aspose.com

Header Issue

Hi

When i try to merge multiple documents with different headers, we have noticed the header from the first document is carried over to the next document if the second document does not have header. If that is known issue or there is a workaround kindly let me know. Please find the sample documents attached.

regards

S.Saba

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think that you should just unlink headers/footers. See the following code:

Document doc1 = new Document(@"Test238\doc1.doc");

Document doc2 = new Document(@"Test238\doc2.doc");

//Loop through all sections in src document

foreach (Section sect in doc2.Sections)

{

//Unlink headers/Footers

sect.HeadersFooters.LinkToPrevious(false);

//Import node

Node dstSect = doc1.ImportNode(sect, true, ImportFormatMode.KeepSourceFormatting);

doc1.AppendChild(dstSect);

}

//Save document

doc1.Save(@"Test238\out.doc");

Hope this helps.

Best regards.