Free Support Forum - aspose.com

Template merging footer issue

Hello Aspose,

I am merging two word template documents.
First template has footers present, and i am using a page break before appending the second template, page break is coming but footer should not be present in the blank page that is created using page break.
In the example i am using there are 6 pages in a template and after adding a page break then the blank page should not have footer as “7”
Can you please let me know how to proceed with this.

@Sharath_kavayah,

Thanks for your inquiry. Please use the following code example to get the desired output. Hope this helps you.

Document dstDoc = new Document(@"test1.dotx");
             
dstDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;
DocumentBuilder builder = new DocumentBuilder(dstDoc);
builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.SectionBreakNewPage);

dstDoc.LastSection.HeadersFooters.Clear();
dstDoc.LastSection.HeadersFooters.LinkToPrevious(false);

Document srcDoc = new Document(@"test2.dotx");

dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

foreach (Section section in dstDoc.Sections)
{
    section.PageSetup.RestartPageNumbering = false;
}

dstDoc.Save(@"C:\temp\out1.doc");