Free Support Forum - aspose.com

Delete Empty page

Hello
After generating doc we have sometimes empty pages on our report doc (because of “Saut de page” inserted).
How can we delete empty pages from report doc ?

Hi,

Sorry, could you please elaborate your question? Are page breaks (I hope I’ve understood you correctly) inserted by your application explicitly or they’re unexpected?

Hi,

page breaks are inserted by our application explicitly because we want to go to the next page(to begin a new paragraph).
But sometimes instead of going to the next page. it goes to the next of the next page. (for example if we insert breaks in page 1, page 2 is blank and page 3 contents the text we wanted to have in page 2).

If possible, please attach your document templates, before and after processing it by Aspose.Word. It is very hard to suggest something without them.

Ok,
I sent you template and output document.

On page 3 of template if merge fields is null, page 3 on output doc is null.
we wanted page 3 to be removed.

Please try to use doc.MailMerge.RemoveEmptyParagraph = true, it should delete the remaining page break on page 3 too.

Hi,
I’ve used doc.MailMerge.RemoveEmptyParagraphs = true;
but the problem remain unresolved !!!

Is it due to Header and footer ?

Note : I’ve inserted Header and footer to all pages .

Probably yes because I’ve tested your template and had the proper result (the page has been removed). Please try to insert headers/footers after mail merge.