We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dealing with widowed Titles and Grid Headers in Syncfusion Pdf

Thread ID:





118028 Jan 21,2015 09:56 PM UTC Jan 28,2015 09:26 AM UTC ASP.NET Web Forms (Classic) 6
Tags: PDF
Benjamin Krug
Asked On January 21, 2015 09:56 PM UTC


     How can I avoid the following issue? The attached program will generate a three page document. The document contains a long body of text, a title above a grid, and a data grid.  The grid title is "Employee Payroll for the month of August 20xx". The body of text is just a bit shorter than the first page, so the text, the grid title, and the grid header each appear on the first page, but all of the data flows onto the second and third.  Thus, the grid header and the grid title are orphaned.  The grid header repeats on the second and third page; which is good, but doesn't solve the problem of the widowed grid header.

     What is the most efficient way to avoid this example of widowed elements?  Assume the following:
  • I don't know until runtime how long the initial body of text will be.
  • I don't know until runtime what the column titles will be.  Thus, I do not know the height of the grid header.
  • I don't know until runtime what the data in the grid will be.  Thus I do not know the height of any particular row.
     All of the above information is acquired from some database.

     Also bear in mind, I do not just want to avoid a widowed grid header, but the grid title "Employee Payroll for the month of August 20xx" must also appear on the same page as the first row of data.  I suppose that I need some way to predict the amount of height that the header row and one data row will take up before I actually draw the grid.  Likewise I need to predict how much height the grid title will take up.  Is there a way to do that?  Is there a way to perhaps mock-draw a grid, but not commit changes?  I am aware that the Syncfusion Draw() function returns an object of type PdfLayoutResult, but that only tells me what space an element takes up after I have committed to drawing it at one particular location.


Attachment: PdfSample__Widows_47469539.zip

Benjamin Krug
Replied On January 21, 2015 10:02 PM UTC


    That first sample might not compile.  Try this instead.


Attachment: PdfSample__Widow_789a7b1.zip

Abirami Selvan [Syncfusion]
Replied On January 22, 2015 05:13 PM UTC

Hi Benjamin ,

 Thank you for using Syncfusion Product .

We have created the workaround  for your requirement .Please refer the attached sample in below link :


Please try this and let us know if you  have any further assistance .



Benjamin Krug
Replied On January 22, 2015 06:36 PM UTC

This is almost what I need, but accessing a grid row's Height property seems to cause the row to collapse.  The grid header has some column names listed that use three lines of text, but I can only see the first line.  Certainly, one could make the argument that the column names in my original sample are too long, but we are assuming that I don't have control over that portion of the design.

Abirami Selvan [Syncfusion]
Replied On January 23, 2015 12:37 PM UTC

Hi Benjamin ,

We can able to provide the height of the Header and Rows manually so that the height will preserve while paginating. We can draw the multiple line text into PdfGridCell , Using  PdfGridHeader and PdfGridRow  Height Property . 

Please refer the following code snippet:

//add the header

PdfGridRow pdfGridHeader = pdfGrid.Headers[0];

//Set the height to the header

pdfGridHeader.Height = 40;

Please refer the attached the sample in below link :


Please let us know if you have any further assistance .



Benjamin Krug
Replied On January 23, 2015 02:37 PM UTC

I am starting with an arbitrary amount of text.  Since I must ultimately have the ability to pull column names and data from a database, I don't know until run time what the text is and so I don't know if the text will require one line or three.  Any algorithm I develop to determine the space taken up by text will be unreliable, because it is very difficult to determine that type of thing when text does not have fixed-width letters.  Therefore, manually setting the row height is unlikely to be a solution for me.

It seems that for a person who does not know much at compile time about the data they will be dealing with, the only reliable way to determine the height of the grid header and the first row before drawing it may be the following.  I could have a second pdf document held in memory and draw the grid header and one grid row to that document.  Then the Syncfusion library will tell me how much space the grid took up on the second document and I will know where to start it on the first document.  I was just wanted to avoid that solution because it seems hacky.  The solution in your first reply was almost the one that would have worked for me.

Abirami Selvan [Syncfusion]
Replied On January 28, 2015 09:26 AM UTC

Hi Benjamin ,

Thanks for your patience .

 We need PdfGridHeader height and first  PdfGridRow  height to check the condition to meet your requirements. But we cannot able to get the PdfGridRow height during run time, as a workaround we draw the PdfGridHeader and first PdfGridRow in temporary  PdfGrid to get the height in run time. Now we can get the resultant height from the  bounds of  PdfGridLayoutResult  while draw the temporary PdfGrid.

We  have attached the sample in below link .



Please try this and let us know if you need any further assistance .





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon