How to remove blank page if there is a page breaker included at the end of foreach in rtf word template

Hi team,

We have a rtf template created using com.aspose.words.Document and then included a page breaker at the end of foreach loop and we observe that there is an empty blank page at the end of template pdf output.

Please help on how to remove the empty blank page where there is a page breaker.

@prudhviyadav Could you please attach your input and output documents along with code that will allow us to reproduce the problem? We will check the issue and provide you more information.

Hi Alex,

I have attached a zip file that has rtf and the pdf output.

Test_PB_TEST.zip (64.8 KB)

@prudhviyadav Thank you for additional information. As I can see on the last page of your template there are only foreach closing tags. You can move them to the previous page. Also, I would suggest you to use Page break before option of the paragraph instead of page break. Please try using the following modified template:
modifeid.zip (8.8 KB)

Hi Alex,

Thank you! but we are looking to have the output in such a way that every PRODUCT CATEGORY should display in a new page and do not have the blank page at the end.

The foreach closing tags are automatically moved to next page upon inserting a page break before end of foreach.

@prudhviyadav The attached modified template will produce exactly the required output. The first paragraph in the modified template has Page break before options set. So when it is repeated, it will go to the next page.