We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to fix the size of an image in a table Cell


I’m trying to create a pdf document with thumbnails of pictures in a table.

I’m using ImageInfo.FixWidth and ImageInfo.FixHeight to set the with and height of the images in the table, but the images always appear larger than expected.

I’ve attached a sample VS.NET solution to illustrate my problem.
In this solution, I create a table with 5 columns, and I set the column widths using

table.ColumnWidths = “20% 20% 20% 20% 20%”.

I’m using 100x50 pixels images, and I want them to be rendered at this size, so I calculate the FixWidth and FixHeight this way :

float fixWidth = pixelWitdh72F/96F;
float fixHeight = pixelHeight72F/96F;

Then I iterate through my images, adding them to the table using :
var cell = row.Cells.Add();
var image = new Image();
image.ImageInfo.ImageStream = …;
image.ImageInfo.FixWidth = fixWidth;
image.ImageInfo.FixHeight = fixHeight;

Despite the use of FixWidth and FixHeight, the images look larger in the pdf (see sample attached).

What am I doing wrong ? Did I miss something in the configuration of the table ?

Thanks for your help.


Hello Pascal,

Thanks for using our products.

If the values for FixWidth and Fixheight are provided in code snippet, then the image placed over PDF document are based over information specified in these properties. If you specify the image dimensions information as specified below, the image seems to be identical to its original size.

image.ImageInfo.FixWidth = 50;
image.ImageInfo.FixHeight = 25;

Please take a look over the attached PDF document that I have generated. I think you need to update the formula that you are using to calculate the dimensions information.

In case I can be of any further assistance, please let me know. We apologize for your inconvenience.


Thanks for your answer.

However there is something that is still unclear to me. Although it’s not mentioned in the API, I’ve read in another forum post that FixWidth and FixHeight should be specified in points.

As far as I know, a point is 1/72 inch. At 96 dpi, the formula to calculate the witdh and height of my image in the PDF should be :

float width = pixelWidth *72 /96;
float height = pixelHeight * 72 /96;

For a 100x50 pixel image, this gives 75x37.5 points.

The formula seems correct according to the method ConvertUtil.PixelToPoint available AsposeWord.

But if I use this formula, the image always look larger than expected, so as you said, the formula must be wrong but I can’t figure out why.

Hi again,

I must be tired, because I just noticed Adobe Reader displayed the doc zoomed at 113%.
At 100%, the images just look fine.

Sorry for the inconvenience and thanks again.