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

Free Support Forum - aspose.com

Is there any functionality for Table header line to repeat across pages

I am working with Aspose.pdf Jar for java. Is there any functionality present for Table header line to repeat across pages in same jar?


Thanks for contacting support.

In order to repeat Table header across the page, you need to set RepeatingRowsCount property of the table object. Please check following code snippet where I have managed to repeat the table header row after page break. For your reference, I have attached an output document as well, which was generated by below code snippet.

Document doc = new Document();
// Add page to PDF document
// Instantiate a table object
Table table = new Table();
// Add the table in paragraphs collection of the desired section
// Set with column widths of the table
table.setColumnWidths("50 50 50");
// Set default cell border using BorderInfo object
table.setDefaultCellBorder(new BorderInfo(BorderSide.All, 0.1F));
// Set table border using another customized BorderInfo object
table.setBorder(new BorderInfo(BorderSide.All, 1F));

// Create MarginInfo object and set its left, bottom, right and top margins
MarginInfo margin = new MarginInfo();
// Set the default cell padding to the MarginInfo object
// Set repeating rows count
// Create rows in the table and then cells in the rows
Row row1 = table.getRows().add();
for (int i = 0; i < 100; i++){
 Row row = table.getRows().add();
 row.getCells().add("item " + i);
 row.getCells().add("item " + i);
 row.getCells().add("item " + i);
// Save the PDF document
doc.save(dataDir + "TableWithRepeatingHeader.pdf");

TableWithRepeatingHeader.pdf (9.6 KB)

In case of any further assistance, please feel free to contact us.

Thanks for quick help :slightly_smiling_face:

I am converting html file into PDF using aspose.pdf. And I want html table header should repeat across pages where the table data is split between the pages. So is there any css setting or any API present in Aspose.pdf jar for getting repeat headers. Please share the detail or code snippet if any.


Thanks for adding more details to the scenario.

I am afraid that currently there is no such feature or property, which Aspose.Pdf supports to repeat the table header across page while converting HTML into PDF. However, would you please share your HTML file with us, so that we can log an investigation ticket and provide our feedback accordingly.