RowFormat.HeadingFormat is not working when repeated rows split into two pages

Hi Team,

I need to display first two rows as headers if table split into multiple pages. But its not working when first two rows of table split into two pages like below screenshot . Below is the code snippet, pls check and suggest.

table.Rows[0].RowFormat.HeadingFormat = true;
table.Rows[1].RowFormat.HeadingFormat = true;

Thanks.

@kiranchallagali Could you please attach your input and problematic output documents here for testing? We will check the issue and provide you more information. I have tested with a simple document created in MS Word and two rows table header works fine.

@alexey.noskov I have a word document that contains text and table ( 1000 rows ), I’m converting document to PDF and while converting I have set first two rows as headers using below code.

table.Rows[0].RowFormat.HeadingFormat = true;
table.Rows[1].RowFormat.HeadingFormat = true;

In PDF, first row displayed in bottom of the 1st page as I have text in top. 2nd row and other rows displayed in 2nd page, in 3rd page, headers are not repeated.

@kiranchallagali Unfortunately, I cannot reproduce the problem on my side. Here is test code:

Document doc = new Document(@"C:\Temp\in.docx");

Table table = doc.FirstSection.Body.Tables[0];

table.Rows[0].RowFormat.HeadingFormat = true;
table.Rows[1].RowFormat.HeadingFormat = true;

doc.Save(@"C:\Temp\out.pdf");

Here are input and output documents:
in.docx (24.3 KB)
out.pdf (49.0 KB)

@alexey.noskov please check the attached files,In this case headers are not repeating even though we applied below code.
in.docx (28.9 KB)
out.pdf (343.6 KB)

table.Rows[0].RowFormat.HeadingFormat = true;
table.Rows[1].RowFormat.HeadingFormat = true;

@kiranchallagali Unfortunately, I cannot reproduce th eproblem on my side using the latest 23.6 version of Aspose.Words. Here is output PDF document produced by the code i have provided in my previous post: out.pdf (109.0 KB)

@alexey.noskov In your case table started in new page but my case first row of the table displayed in first page, 2nd and other rows are displayed on other pages.

If the first two rows of the table don’t fit on one page, is there a way to move to the next page?

@kiranchallagali The output PDF document I have attached in my previous response was generated from your DOCX document with the following code:

Document doc = new Document(@"C:\Temp\in.docx");

Table table = doc.FirstSection.Body.Tables[0];

table.Rows[0].RowFormat.HeadingFormat = true;
table.Rows[1].RowFormat.HeadingFormat = true;

doc.Save(@"C:\Temp\out.pdf");

Ans using the latest 23.6 version of Aspose.Words. It looks like you are using some older version of Aspose.Words.
In general if you would like to keep rows together, you can enable Keep With Next option for paragraphs in the first table row. But As I have mention no such manipulations are required with the latest version of Aspose.Words.