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?

@ksushant

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
doc.getPages().add();
// Instantiate a table object
Table table = new Table();
// Add the table in paragraphs collection of the desired section
doc.getPages().get_Item(1).getParagraphs().add(table);
// 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();
margin.setLeft(5f);
margin.setRight(5f);
margin.setTop(5f);
margin.setBottom(5f);
// Set the default cell padding to the MarginInfo object
table.setDefaultCellPadding(margin);
// Set repeating rows count
table.setRepeatingRowsCount(1);
// Create rows in the table and then cells in the rows
Row row1 = table.getRows().add();
row1.setBackgroundColor(Color.getGreen());
row1.getCells().add("col1");
row1.getCells().add("col2");
row1.getCells().add("col3");
		
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.

@ksushant

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.