Repeating rows in an HTML Table

Hello,


Is it possible to repeat the header row of an HTML table if the table is split due to a page break?

Is this something accomplished in the HTML or on the PDF object itself?

Currently we dynamically generate HTML then write it to a PDF in memory via something like this:
bodyHtml is a dynamically generated html string.
Pdf pdf = new Pdf(); 
Aspose.Pdf.Generator.Section bodySection = pdf.Sections.Add();
Text text = new Text(bodySection, bodyHtml);
text.IsHtmlTagSupported = true;
bodySection.Paragraphs.Add(text);
MemoryStream outStream = new MemoryStream();
pdf.Save(outStream);

Thanks!

Hi Dan,


Thanks for using our products.

When trying to render HTML page to PDF format, Aspose.Pdf for .NET tries to convert the exact contents present in source HTML. So as per your requirement, you need to have the repeating Header row on source HTML.

Besides this, Aspose.Pdf for .NET supports the feature to create Table inside PDF file and in case you need to repeat the Header of table on consecutive pages, you simply need to set the value of IsFirstRowRepeated property of Aspose.Pdf.Generator.Table class to true. You may also try using RepeatingRows property of Table class to sets a int value that indicates how many rows from the first row will be repeated when the table is broken across pages.

In case you encounter any issue or you have any further query, please feel free to contact.

Thanks for the reply.


Given my code sample above, would my HTML tables be converted into Aspose “Table” objects within the Pdf object? Or is HTML handled differently?

Is there a way to extract all “Table” objects from the Pdf object and manually set the “RepeatedRows” property? All of the tables in my Pdf would need repeated header rows.


fuller:
Given my code sample above, would my HTML tables be converted into Aspose “Table” objects within the Pdf object? Or is HTML handled differently?
Hi Dan,

The Tables inside PDF document are created based on Document Object Model and Table is treated as paragraph level object. However the mechanism of rendering HTML to PDF is different and Aspose.Pdf cannot deal/manipulate HTML table.

fuller:
Is there a way to extract all “Table” objects from the Pdf object and manually set the “RepeatedRows” property? All of the tables in my Pdf would need repeated header rows.
Currently Aspose.Pdf for .NET does not support the feature to extract table from PDF file. However we already have logged this requirement as PDFNEWNET-29904 in our issue tracking system. Once this feature is supported, you will get the capability to extract table, alter it and place it back in PDF file.

As a workaround, you may consider adding a table with one row (showing repeating row) on subsequent pages. For further details, please visit Add Table in Existing PDF Document