Blank pages are removing after append document

Hi,

I am creating multiple small document and appending it in a one document. In my small document sometimes I will add section break and page break for a blank page. When that document append with other it will remove the blank page from it. Please help me to retain that blank page.

Sample File Main.zip (2.8 KB) , input filetestInput.docx (14.8 KB) and output file output.docx (12.0 KB)

I am attaching a sample document to reproduce the issue. In the output document I need a blank page after the page which as “separator page” title. So please help me to fix the issue

Thank you

@Gptrnt MS Word suppresses page break at the end of the section. If you take a look at your output document you can see that page break is there, but MS Word does not show it:

This behavior depends on the MS Word version used to create document. If optimize the document to MS Word 2003, MS Word will show the empty page:

doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2003);

But in this case the document will be opened in MS Word in compatibility mode.

Alternatively, you can simply put a whitespace after a page break to force MS Word to show an empty page:

builder.insertBreak(BreakType.PAGE_BREAK);
builder.write(" ");

Its working fine Thank you.

1 Like