Thank you for reporting this problem to us. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.
Best regards,
Thanks for your request. Currently I cannot provide you any reliable estimate regarding this issue. You will be notified as soon as it is resolved.
But you can use a very simple workaround. It seems DOCX allows insert page break in sequence on the same row with paragraph break. However, if you try to save this document in DOC format using MS Words, you will see that paragraph break will be moved to the next row and you will get the same result as Aspose.Words returns.
As a workaround, you can try using Section Break (Next Page) instead of Page Break.
The modified document is attached.
Best regards.
However, saving as DOC is not an option because everything is based on the OpenXML standard of DocX. The SectionBreak isn’t really an option to implement at high volume because it also defines other things like header / footer heights.
Thank you for additional information. I have one more way to work this problem around. You can try using ParagraphFormat.PageBreakBefore. Please see the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("This is the First page");
builder.CurrentParagraph.ParagraphFormat.PageBreakBefore = true;
builder.Writeln("This is the second page");
builder.CurrentParagraph.ParagraphFormat.PageBreakBefore = false;
doc.Save("out.pdf");
Thank you for the work around. However the documents are constructed in Word and merged using OpenXML. We use Aspose.Words for the PDF conversion. We don’t build documents from scratch in Aspose.Words
I tested the “save as doc” behavior and it does the same thing as Aspose.Words does. After that I can remove the “extra” added paragraph and everything is correct. If I save that back to .docx it is still correct.
I noticed the PageBreak covers a full line in this case. In the regular docx behavior it is followed by a paragraph sign. So instead of using a section break, I can use a regular page break and remove the paragraph sign after the page break. This will give the correct behavior. I think the code you gave me creates the same construction. See Attachments. This is a workable solution until the fix is ready.
Thanks for your request. Could you please attach your input and output documents here for testing? I will investigate the issue and provide you more information.
Best regards,