Append document with page break

I’m trying to append a document “open TO DO’s” to an existing document “report” and have the “open TO DO’s” document appear on a new page.

I’m building the “report” document by appending several other documents to the end of the document every time. However, I’d like the “open TO DO’s” document to appear on a new page.

I’m following this guide:
https://docs.aspose.com/words/net/insert-and-append-documents/

openTodosDt.TableName = "ToDo";

var openTodosSection = new Document("todo-section.docx");

openTodosSection.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;

openTodosSection.MailMerge.Execute(new[] {"Header"}, new object[] {"All open TO DO’s"});

openTodosSection.MailMerge.ExecuteWithRegions(openTodosDt);

report.AppendDocument(openTodosSection, ImportFormatMode.KeepSourceFormatting);

Regardless is I use:

openTodosSection.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;

or

openTodosSection.FirstSection.PageSetup.SectionStart = SectionStart.Continuous;

the open TO DO’s document is appended at the end of the report document (and not on a new document as I would like).
What am I doing wrong?

Hi Morten,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words generated output document showing the undesired behavior
  • Source code (standalone console app) without compilation errors to reproduce the issue on our end
  • Your expected Word document which shows the correct output. Please create this document using Microsoft Word application.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,