Table header is displayed not at intended page

Hello
We are experiencing problem related to table header display. The table header in the first page is rendered without any body.
The table is rendered in the next page. The header in the previous should not be rendered
ended
Please see attached console application for the problem. Let me know if you need any additional information.

Thanks
Aspose Console 1.zip (2.7 MB)

@ANDREA.FARRIS

It seems you are experiencing an issue where the table header is being rendered on the first page without any corresponding body content, while the actual table body appears on the next page. This can happen if the table is not properly set to render on a new page or if the layout settings are not correctly configured.

To ensure that the table header is displayed correctly and only on the page where the table body is located, you can use the setInNewPage(true) method for the table. This method forces the table to start rendering on a new page, which can help in keeping the header and body together.

Here is a sample code snippet that demonstrates how to force a table to render on a new page:

import com.aspose.pdf.*;

public class ForceTableRenderingOnNewPage {
    public static void main(String[] args) {
        // Create a new document
        Document doc = new Document();
        Page curPage = doc.getPages().add();

        // Create a table
        Table table = new Table();
        table.setColumnWidths("100 100");

        // Add rows to the table
        for (int i = 1; i <= 10; i++) {
            Row row = table.getRows().add();
            Cell cell1 = row.getCells().add();
            cell1.getParagraphs().add(new TextFragment("Header " + i));
            Cell cell2 = row.getCells().add();
            cell2.getParagraphs().add(new TextFragment("Content " + i));
        }

        // Set the table to render on a new page
        table.setInNewPage(true);
        curPage.getParagraphs().add(table);

        // Save the document
        doc.save("output.pdf");
    }
}

In this example, the table is created and configured to render on a new page, ensuring that the header and body are displayed together without any overlap or misalignment.

If you continue to experience issues, please check the layout settings of your document and ensure that there are no other elements interfering with the table rendering. If you have any additional information or specific code snippets, feel free to share them for further assistance.

Sources:
[1]: ForceTableRenderingOnNewPage.java

This is PDF.NET issue. Plese check attached console application for details.

Thanks

@ANDREA.FARRIS

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-59126

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.