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

Free Support Forum - aspose.com

How to prevent table splitting in document?

Hi,

I am preparing a word document from HTML text. The document is used for notification letters and that single document is containing so many letters having page breaks between letters. At the end of each letter there is a table with some salutation and signature image. That is getting broken if the letter text(that is dynamic) is having large data. I need to display the block in the next page if this case occurs.

I have tried by setting properties in html table for that perticular block like page-break-inside:avoid and also IsBroken="false". But both did not work.

Please suggest some solution for this issue. What attribute do i need to set in html table to make it working fine?

Thanks in advance.

Hello

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Could you please attach your input HTML and the output document here for testing? I will check the problem on my side and provide you more information.

Best regards,

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. To prevent table from splitting, you should specify style=" page-break-after:avoid" for each paragraph in the table. This attribute will be translated to “Keep with Next ” option of paragraph in Word document. This will prevent table form splitting. For instance see the following HTML:

<html>

<body>

<div>

<p>This is simple text</p>

<p>This is simple text</p>

<table cellspacing="0" cellpadding="0" style="border-collapse:collapse; margin-left:0pt">

<tr>

<td>

<p style="page-break-after:avoid">Test</p>

</td>

</tr>

<tr>

<td>

<p style="page-break-after:avoid">Test</p>

</td>

</tr>

<tr>

<td>

<p style="page-break-after:avoid">Test</p>

</td>

</tr>

</table>

</div>

</body>

</html>

Hope this helps.

Best regards,

Hi,

Thanks for your reply!

Please find attached zip file that contains both HTML and output word document. Please analyse that and provide solution.

Thanks again.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. It would be great if you also attach an expected output. This will help us to better understand your requirements.

Best regards.

Hi,

Please find the attached zip file for the output document expected to be generated from HTML. The lines starting from "Regards" statement at the bottom of the letter should be displayed on the next page only when that table gets splitted but not each time. The text above that is not fixed, that comes from database.

Thanks.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You should modify your HTML as I suggested in my previous answer, i.e. specify style=" page-break-after:avoid" for each paragraph in the table. But in your case, you need specify this option only for the last nested table.

For instance, in your HTML you have the following:

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td align="left">

Regards,<br />

Hudson Advisors, LLC

</td>

</tr>

You should modify it as shown below:

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td align="left">

<p style="page-break-after:avoid">Regards,<br />

Hudson Advisors, LLC</p>

</td>

</tr>

Best regards,

Hi,

This is working fine now after applying the changes.

Thans very much for the solution !!!

Now i am having some another problem with the same document.

I want the header image and footer image on each page of the word document.

Can you please provide the method or code for that?

Thanks.