Assembling a new word document using other word documents

Good day,
I am creating a new word document by appending other documents contents after each other. I am therefore using the continuous section option. I have realised that if all the documents contents appened after each other are longer than a page, it overlaps the content of the new document on the first page. Please let me know if there is a way of having the remaining content created on a new page instead of overlapping the first page. I am not sure I am being very clear here :-).
Regards
Stephanie

Hi
Thanks for your request. Could you please attach sample documents that could allow me to reproduce the problem? Also please provide me your code. I will investigate the issue and provide you more information.
Best regards.

Hi Alexey,
Thanks for coming back to me. I have attached the 3 files and below is the code (I also convert the document to PDF). Please let me know what your findings are.

public void Convert()
{
    MemoryStream MemoryStream = new MemoryStream();
    MemoryStream PDFMemoryStream = new MemoryStream();
    Document Document2 = null;
    Aspose.Words.License WordLicense = new Aspose.Words.License();
    WordLicense.SetLicense("Aspose.Custom.lic");
    Aspose.Pdf.License PDFLicense = new Aspose.Pdf.License();
    PDFLicense.SetLicense("Aspose.Custom.lic");
    try
    {
        Document Document = new Document(new MemoryStream(_inputFiles[_inputFiles.Length - 1]));
        if (_inputFiles.Length > 1)
        {
            for (int i = _inputFiles.Length - 2; i >= 0; i--)
            {
                foreach (Section srcSection in Document)
                {
                    Document2 = new Document(new MemoryStream(_inputFiles[i]));
                    Section newSection = (Section)Document2.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
                    // Append content of the src section to last section of dst document
                    Document2.LastSection.AppendContent(newSection);
                }
                Document2.Save(MemoryStream, SaveFormat.AsposePdf);
            }
        }
        else
        {
            Document.Save(MemoryStream, SaveFormat.AsposePdf);
        }
        Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
        // Bind content from the named xml file.
        pdf.BindXML(MemoryStream, null);
        // Save the result
        pdf.Save(PDFMemoryStream);
        _outputFile = PDFMemoryStream.GetBuffer();
    }
    catch (Exception ex)
    {
    }
}

Hi
Thank you for additional information. You can just set section start = NewPage. As shown in the following code:

Document doc1 = new Document(@"Test195\email.xml");
Document doc2 = new Document(@"Test195\contact+details.xml");
doc2.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
doc1.AppendDocument(doc2, ImportFormatMode.KeepSourceFormatting);
doc1.Save(@"Test195\out.doc");

This gives me much better result than Continuous section start.
Best regards.

Thanks Alexey,
But wouldn’t this put the 2 ENTIRE documents on 2 totally different pages? I would like to get them to be right under each other and whatever cannot fit from the 2nd document on the 1rst page to go to the 2nd page. Is it possible to do such a task?
Regards
Stephanie

Hi
Thanks for your inquiry. Unfortunately there is no way to detect when pages starts and ends. Aspose.Words document represents content and formatting of a document, not its layout into lines and pages.
Best regards.