Hi David,
Thanks for your inquiry. Please set the value of PageSetup.SectionStart property as SectionStart.Continuous if you do not want to start the content on next page.
You may use DocumentBuilder.InsertDocument method and insert the header/footer contents from one document into another document. After inserting the contents of one document into another using DocumentBuilder.InsertDocument, please use MergeHeaderFooter method to merge header/footer contents of documents. Hope this helps you.
If you still face problem, please share your expected output document here for our reference. We will then provide you more information about your query along with code.
Document doc1 = new Document(MyDir + "doc1.docx");
Document doc2 = new Document(MyDir + "doc2.docx");
MergeHeaderFooter(doc1, doc2, HeaderFooterType.HeaderPrimary);
MergeHeaderFooter(doc1, doc2, HeaderFooterType.FooterPrimary);
doc2.Save(MyDir + "Out.docx");
public void MergeHeaderFooter(Document srcDoc, Document dstDoc, HeaderFooterType headerType)
{
foreach (Section section in dstDoc.Sections)
{
HeaderFooter header = section.HeadersFooters[headerType];
if (header == null)
{
// There is no header of the specified type in the current section, create it.
header = new HeaderFooter(section.Document, headerType);
section.HeadersFooters.Add(header);
}
foreach (Node srcNode in srcDoc.FirstSection.HeadersFooters[headerType].ChildNodes)
{
Node dstNode = dstDoc.ImportNode(srcNode, true, ImportFormatMode.KeepSourceFormatting);
header.AppendChild(dstNode);
}
}
}