PageBreak is not finishing paragraph

Hi Aspose team,

looks like inserting PageBreak doe not finishes current paragraph. This causes the formatting set after PageBreak to also be applied to whatever paragraph was set before it. In word inserting PageBreak causes paragraph end mark to appear in the same lane as PageBreak, basically finishing the paragraph. Please use following code snippet to replicate this issue:

            var doc = new Document();
            var builder = new DocumentBuilder(doc);
            builder.InsertBreak(BreakType.LineBreak);
            builder.Write(ControlChar.PageBreak);
            builder.Write("test");
            var border = builder.ParagraphFormat.Borders.Top;
            border.Color = Color.Black;
            border.LineWidth = 1;
            border.LineStyle = LineStyle.Double;
            doc.Save(@"D:\test.docx");

I’ll not push for this being fixed if there is some workaround we can apply to achieve the same as word does without inserting additional lines into the document. Could you please help me out with this?

Thanks,
Mateusz

@acturisaspose

You are facing the expected behavior of Aspose.Words. You are inserting line break and then page break into the document. To get the desired output, please insert paragraph break and then page break as shown below.

var doc = new Document();
var builder = new DocumentBuilder(doc);

builder.InsertBreak(BreakType.ParagraphBreak);
builder.Write(ControlChar.PageBreak);
builder.Write("test");
var border = builder.ParagraphFormat.Borders.Top;
border.Color = Color.Black;
border.LineWidth = 1;
border.LineStyle = LineStyle.Double;

doc.Save(MyDir + "output.docx");