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

Free Support Forum - aspose.com

Keep tables on the same page - HTML to PDF

Hi guys,


We are trying to generate a PDF from HTML content which has a number of tables. We are finding that content of tables is spilling onto a second page which looks untidy when it prints. For example the heading and first row are on one page and the other rows are on a second page. I know we can use something like <div style=page-break-after:always></div> to explicitly force a page break, but we’d rather a solution where we can simply specify that if the contents of ANY table spill onto a new page we can just put the whole table onto the second page rather than having bits of the table on two pages. I’ve tried this:

<div style=page-break-after:auto>
<table class=“main”>
</table>
</div>

…but the Aspose tool throws a NullReferenceException.

Do you know how I can solve this?

Thanks

Hi Pranav,


Thanks for contacting support.

When converting HTML to PDF, we cannot control the page break and during conversion, our API tries to render the tags inside resultant PDF file. Can you please share the source HTML so that we can test the scenario at our end. We are sorry for your inconvenience.