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.
Unfortunately, activation email could not send to your email. Please try again.

Dealing with widowed Titles and Grid Headers in Syncfusion Pdf

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Hi,

     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.

thanks,
Ben

Attachment: PdfSample__Widows_47469539.zip

Benjamin Krug
Replied On January 21, 2015 05:02 PM

Sorry,

    That first sample might not compile.  Try this instead.

Ben

Attachment: PdfSample__Widow_789a7b1.zip

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

Hi Benjamin ,

 Thank you for using Syncfusion Product .

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

http://www.syncfusion.com/downloads/support/directtrac/general/PdfSample-1747067167.zip

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

Thanks,

Abirami.


Benjamin Krug
Replied On January 22, 2015 01:36 PM

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 07:37 AM

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 :

http://www.syncfusion.com/downloads/support/directtrac/general/PdfSample-1353251785.zip

Please let us know if you have any further assistance .

Thanks,

Abirami.


Benjamin Krug
Replied On January 23, 2015 09:37 AM

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 04:26 AM

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 .

http://www.syncfusion.com/downloads/support/directtrac/general/PdfSample1783140261.zip

 

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

 

Thanks,

Abirami.


CONFIRMATION

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.

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.

;