Empty page when table is to high

Hi,

When I am using a docx template and saving it as a pdf, sometimes the table is to high and will result in an empty page.

As a solution I check on rows of the table and remove \r\n by replacing it with an empty string. This does not always work. Sometimes an empty page or the next right page below the table without a page break.

It is a better solution to check the content and when no content on a page, remove the page.

Any idea how to remove empty pages?

Kind regards,

Roel

Hi Roel,

Can you send us your DOCX file so that we can investigate it?

This removal of “\r\n” that you’re referring to, I’m guessing that is what you get from Content.ToString() which would indicate that you have an empty paragraph in that content range. By loading an empty string in its place you’re basically replacing one empty paragraph with another.

Anyway, if you’re getting an empty page then I presume there are some empty paragraphs at the end of your document. So the solution would be to remove those last paragraphs. However, without investigating your document I cannot say anything for sure.

Regards,
Mario

The empty page occurs because of the following paragraph that contains the PageBreak element:

image

That paragraph most likely doesn’t fit on the same page where the table is inserted and thus it is moved to the next page.

You could consider changing your template document to better fit your requirements.
For instance, instead of that PageBreak element, you could set the PageBreakBefore option in the next paragraph:

I hope this helps.

Regards,
Mario