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. Image for the cookie policy date

Image in PdfGridCell keeping aspect ratio


I have a PDF with a grid and I want to have different images in different cells. These images have different size and aspect ratio, but all the cells are the same size. I want to add the images to cells and keep the same aspect ratio as the original image, but when you insert them as background images they are resized and streched to fit the cell.

I.e. have a picture that's 1000x500 px and a cell that's squared (same width and height). If i put this inside a PdfGridCell as a background image, it's streched so that the width and height is the same, and looks distorted. 

Is there any way I can insert it into a PdfGridCell and force it to keep the same aspect ratio ? Or do I have to find out the height and width of a PdfGridCell in pixels, resize the image with the same aspect ratio to a Image that will fit the cell and then add it ? Or perhaps PdfLightTable have any support for inserting images into cells keeping the aspect ratio ?

Thanks in advance :)

3 Replies

KC Karthikeyan Chandrasekar Syncfusion Team October 11, 2013 05:32 AM UTC

Hi Truls,

Thank you for using Syncfusion Products.


We can able to keep the same Aspect Ratio of the image into the Pdf Grid cell, please use the below property to position the background image to center with the same aspect ratio. Please let us know if this code snippet satisfied your requirement.

Code Snippet:

            pdfGrid.Rows[0].Cells[1].ImagePosition = PdfGridImagePosition.Center;


Please let us know if you need any further assistance.




TR Truls Rødfjell October 11, 2013 06:33 AM UTC


On images that can fit the cell, the image is centered in the cell, but on images larger then the cell itself - the image is just rescaled to the max height and width of the cell (ignoring the aspect ratio). 

Example: Image is 100x50 and the cell is 50x50 px... the image will be resized to 50x50 - I want the image to be resized to 50x25 before it's inserted into the cell.

Is there any way I can find the height and the width of a cell, and the image that I'm going to insert into the cell, in points so I can resize it before inserting it ?

If this is not supported, any other components I can use instead of the PdfGridCell for this purpose ?


KC Karthikeyan Chandrasekar Syncfusion Team October 14, 2013 09:59 AM UTC

Hi Truls,

Thank you for your update.


The image can be fit into the Pdf Grid cell by using the following code snippet.

Please use the below code snippet:

            pdfGrid.Rows[0].Cells[1].ImagePosition = PdfGridImagePosition.Fit;

Also we have found an issue in our product that when the image width is greater than the image height Fit is not working properly. Please create a Direct trac incident with the title “Forum- 113776- Image in PdfGridCell keeping aspect ratio” for getting the patch for this issue.


Please let us know if you have any concern.




Live Chat Icon For mobile
Up arrow icon