Append document and keep page numbers

Hello,

I want to append a document to another document and keep the original paging on the appended document. Is there a way to do this without converting to PDF or image?

I have tried unlinking the page number fields but there isn’t a section break between all footers so the first page number is used on all footers for a section.
Is there maybe a way to add a continuous section break on all pages and unlinking footers from previous?

Any help appreciated.

Thanks

@roberto.silva Please try using Merger class to merge the documents together with MergeFormatMode.KeepSourceLayout:

string[] documents = new string[] { @"C:\Temp\in1.docx", @"C:\Temp\in2.docx" };
Aspose.Words.LowCode.Merger.Merge(@"C:\Temp\out.docx", documents, SaveFormat.Docx, Aspose.Words.LowCode.MergeFormatMode.KeepSourceLayout);

In this case original document layout should be preserved.

Thanks Alexey but we don’t have a license for a version with LowCode available.
Is there a solution for up to v23.3?

Thanks

@roberto.silva Try using the following code:

Document doc1 = new Document(@"C:\Temp\in1.docx");
Document doc2 = new Document(@"C:\Temp\in1.docx");
doc2.FirstSection.HeadersFooters.LinkToPrevious(false);
doc2.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
doc2.FirstSection.PageSetup.RestartPageNumbering = true;
doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);
doc1.Save(@"C:\Temp\out.docx");