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.
Syncfusion Feedback

PdfGrid: size grid to content

Thread ID:

Created:

Updated:

Platform:

Replies:

131302 Jul 3,2017 10:11 PM UTC Jul 7,2017 11:32 AM UTC Xamarin.Forms 6
loading
Tags: PDF
Malcolm Jack
Asked On July 3, 2017 10:11 PM UTC

Is it possible to resize a pdfGrid columns to content?
In Xaml I'd do something like:
Column Width = "*"
Column Width = "Auto"
Column Width = "Auto"

ie: Column 1 would stretch to available space
Column 2 & 3 would auto-align to content.

Surya Kumar [Syncfusion]
Replied On July 4, 2017 12:03 PM UTC

Hi Malcolm, 
 
Thank you for using Syncfusion products. 
 
When width of one of the column is set then, other columns will resize automatically in PdfGrid, please refer the below UG documentation link for customization of columns in PdfGrid. 
 
Documentation link: 
 
Please let us know if you need any further information in this. 
 
Regards, 
Surya Kumar 


Malcolm Jack
Replied On July 4, 2017 12:43 PM UTC

Hi Surya,

That's handy if you know what the max length of the content will be.

But with runtime data, you don't know the max content width at design time, so you can't set column width.

Would be great of the was the "Auto" / "*" convention like in xaml - but I assume there isn't.

I would imagine the best way to do this would be to cycle through the content, and find the max length using MeasureString on the text, and then set the column width accordingly?

Malcolm


Surya Kumar [Syncfusion]
Replied On July 5, 2017 07:22 AM UTC

Hi Malcolm, 
  
We have created the sample as per your requirement for resizing the width of the PdfGrid column as per the maximum width of contents in the respective column, by iterating through each contents and setting the string with maximum width as the column width. 
  
Please find the sample link below: 
  
Please find the final output document from the link below: 
  
Let us know if you need any further information in this. 
  
Regards, 
Surya Kumar 


Malcolm Jack
Replied On July 5, 2017 08:44 PM UTC

That's fantastic - thx :)

Would be great if in future releases this was easier to do - I would imagine it's a fairly common requirement for column widths.



Malcolm Jack
Replied On July 5, 2017 09:32 PM UTC

Hi Surja,

I tried to apply the same logic to the PdfLightTable column - but it doesn't have the same effect.

Is there a bug with the pdfLightTable?

You can find a repo with sample code here


Malcolm


Surya Kumar [Syncfusion]
Replied On July 7, 2017 11:32 AM UTC

  
Hi Malcolm,  
 
 
We were able to reproduce the issue and we have confirmed this as bug and logged a report on this. Also, we have created a support incident under your account to track the status of this issue.  
 
                                                      
Please log on to our support website to check for further updates.  
 
Please let us know if you have any questions.  
  
 
Thanks,  
Surya Kumar.  


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.

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

;