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

Free Support Forum - aspose.com

setBroken(false) not working on table

we create a PDF document from scratch and add some tables into it. For some tables we do not allow them to be broken / split to the next page.
So we use
Table table = new Table();
But it does not work: The first part of the table is on the old page, then the document ends all of the sudden.
Can you help?


Thank you for contacting support.

Would you please try to set it with below code and then share your kind feedback with us.

Table table = new Table();

In case you still face the problem then share SSCCE code with sample PDF documents so that we may try to reproduce and investigate the scenario in our environment. Moreover, before sharing requested data, please ensure using Aspose.PDF for Java 19.2.


unfortunately, table.setBroken(false) is just ignored.

I have attached code to reproduce the issue with aspose 19.2
tableBreak.zip (5.4 KB)

When run, this document is generated:
output_Normal.pdf (52.2 KB)

Please see Line 244 (table.setBroken(false)), if uncomment then this report is generated. The table is cut and the document ends
output_setBrokenFalse.pdf (50.0 KB)

If Line 247 is uncommented (setBroken(TableBroken.None)), setBroken is just ignored.
output_TableBrokenNONE.pdf (52.2 KB)


Thank you for sharing requested data.

We have logged a ticket with ID PDFJAVA-38454 in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.


We have further investigated the ticket and would like to share with you that the behavior of setBroken(false) method is correct. Because if the table should could not be fit completely it should be cut. The setBroken(TableBroken.None) method is only for vertical break for wide tables.

If the required behavior is to move the table completely to new page then table’s height calculation should be used with the method: table.setInNewPage(true);

Also you should take into account the situation where table can not be placed at the page completely, to avoid situation when it will be moved continuously if table is bigger than the page.

Add the following code at the end of the your method: writeServiceProtocolList()

 public void writeServiceProtocolList() {
 //        add this logic to estimate the real table height
        double currentTableHeight = table.getHeight();
        if (currentTableHeight > 297.0 * FACTOR_MM_TO_POINTS)
            throw new PdfException("The table cannot be placed at the page without break");
        if (currentTableHeight + tableHeightCounter > 297.0 * FACTOR_MM_TO_POINTS) {
            tableHeightCounter = 0;
        } else {
            tableHeightCounter += currentTableHeight;


    //add also this field
    double tableHeightCounter = 0; 

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

is there in the meantime an easier way for this behavior:
Say a page has height 10. I add some content with the heigt 6 to the page. Remaining heigth: 4
Now i have a table with height 5.
But on the page, only height 4 is available (10-6).
If a now add this table, i want Aspose to add a new page and add the table to it, because i do not want the table to be broken.


Thank you for elaborating it.

As shared earlier, table can be moved to new page with setInNewPage method while checking if height of table is bigger than specific range. We are afraid any other option may not be available for this scenario.


did you ever got an answer for this? Having the same issue.


We have responded to your similar concerns in your original thread where we requested for sample file and code snippet so that we can try to test the case in our environment and address it accordingly.