We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

When using builder.insertBreak(BreakType.PAGE_BREAK); adds a paragraph break to the next page

When using document builder to insert a page break using the following code

builder.insertBreak(BreakType.PAGE_BREAK);

it adds a paragraph break to the inserted/next page. I need a way to either prevent this or remove the added paragraph tag.

@paul.calhoun,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. If you perform the same scenario using MS Word, you will get the same output.

Could you please ZIP and attach your input and expected output Word documents? We will then provide you more information about your query.

See the uploaded graphic for the issue.

image.png (49.2 KB)

@paul.calhoun,

Thanks for your inquiry. It seems that you are inserting the page break inside table. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

The page break is NOT being inserted inside the table but happens EVERY time a table is created AFTER a page break is added. Here is the graphic as well as source files to that demonstrate the problem.

image.png (51.8 KB)
Temp.zip (6.3 KB)

@paul.calhoun,

Thanks for sharing the detail. The CompatibilityOptions.SplitPgBreakAndParaMark property always move paragraph mark to page after a Page Break. You need to disable this property as shown below to get the desired output.

builder.insertHtml("html text");

builder.getDocument().getCompatibilityOptions().setSplitPgBreakAndParaMark(false);
builder.getDocument().save(MyDir + "output.docx");