Extra newline after concatenating two documents into one with page break

I have two separate word documents, each with one line of text. When I attempt to insert them into a master document by concatenating the two with a page break in between, I see extra newlines. I have taken a screenshot of the result, as well as attached a sample app to illustrate this. This was reproducible with the latest Word dll (11.11.0.0).

Can someone advise how to get rid of these extra lines at the beginning of each new page? Is this a bug in Aspose?

Hi Ann,

Thanks for your inquiry. Please do the following changes in your code:

Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense("Aspose.Words.lic");
// doc1 has "firstdoc" line
var mydoc1 = new Document();
var mywordDocBuilder1 = new DocumentBuilder(mydoc1);
mywordDocBuilder1.Write("firstdoc");
mydoc1.Save(@"C:\temp\doc1.docm");
// doc2 has "seconddoc" line
var mydoc2 = new Document();
var mywordDocBuilder2 = new DocumentBuilder(mydoc2);
mywordDocBuilder2.Write("seconddoc");
mydoc2.Save(@"C:\temp\doc2.docm");
// final doc is to concatenate doc1 and doc2 with a page break in between
var mydoc = new Document();
var mywordDocBuilder = new DocumentBuilder(mydoc);
Section sec = mydoc.LastSection;
Paragraph p1 = sec.Body.LastParagraph;
InsertDocument(p1, mydoc1);
// Just insert a Page Break at the start of Document that is to be inserted next
mywordDocBuilder2.MoveToDocumentStart();
mywordDocBuilder2.InsertBreak(BreakType.PageBreak);
Paragraph p2 = sec.Body.LastParagraph;
InsertDocument(p2, mydoc2);
// Remove first empty Paragraph
sec.Body.FirstParagraph.Remove();
mydoc.Save(@"C:\temp\finaldoc.docm");
Console.WriteLine("done");
Console.Read();

I hope, this helps.

Best regards,