Inserting document with more Continuous section breaks switch last section break to Next Page type

I am inserting one document into another.

Destination document has only few paragraphs. Source has 2 section breaks - Continuous.
When I insert source document into destination, second section break will become Next Page that is not valid. I have tried also with case where source document has more than 2 section breaks of type Continuous. Last section break will be always switched to Next Page. All others remain as they were before. In case when last one section break is of type Next Page, than everything will be OK Code snippet - InsertFile method

One more issue/question. Destination document has one column text. Source document starts with 2 columns text and has after it one section break Continuous. By default after insertion first section in destination document becomes 2 columns text that I do not expect. Looks like formatting from source document was taken. I can bridge this by setting column text like : SetColumnText method.

public static void InsertFile()
{
Document destDoc = new Document(“FirstSection.docx”);
Document sourceDoc = new Document(@“SecondSection.docx”);

DocumentBuilder builder = new DocumentBuilder(destDoc);
builder.MoveToDocumentEnd();
builder.InsertDocument(sourceDoc, ImportFormatMode.KeepSourceFormatting);
string documentName = Guid.NewGuid() + “.docx”;
destDoc.Save(documentName, SaveFormat.Docx);
}


public static void SetColumnText (Document sourceDoc, Document destDoc)
{ sourceDoc.FirstSection.PageSetup.TextColumns.SetCount(destDoc.LastSection.PageSetup.TextColumns.Count);
sourceDoc.FirstSection.PageSetup.TextColumns.EvenlySpaced = destDoc.LastSection.PageSetup.TextColumns.EvenlySpaced;
sourceDoc.FirstSection.PageSetup.TextColumns.LineBetween = destDoc.LastSection.PageSetup.TextColumns.LineBetween;
sourceDoc.FirstSection.PageSetup.TextColumns.Spacing = destDoc.LastSection.PageSetup.TextColumns.Spacing;
}

Hi Rastko,


Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you insert the contents of “SecondSection.docx” at the end of “FirstSection.docx” using MS Word, you will get the same output.

Regarding column break query, the first section of “SecondSection.docx” has two columns. This is the reason you are getting two columns in final output document. Yes, you can use SetColumnText method to get the desired output related to column break.

Please let us know if you have any more queries.

OK Tahir.


Thank you for your clarification