Free Support Forum - aspose.com

Image width in PDF

Hi

I have placed an Image in the PDF file and trying to adjust the size of it. It is not working. I have an XML file as the source for PDF. I have an Image tag.

<Cell FitWidth=“250” ColumnsSpan=“5” PaddingLeft=“10” PaddingRight=“10” PaddingBottom=“5”>

<Image Type=“gif” File = “C:\inetpub\wwwroot\multirater\images\reports\square-blue.gif” Width=“200” >

</Image>

</Cell>

But the above code is not working. The output has the original Image size. If I set the FixWidth property, it is scaling the image. I want the height to be same and only the width to increase or decrease depends on the Width.

Thanks
Jay

Dear Jay,

Thank you for consideirng Aspose.

You should use the “FixWidth” property to set the image width. But in Aspose.Pdf, image width and height will has fixed scale so you can’t let the height to be the same and change the width. If you have to do this, please change the image before adding it to the PDF ducument.

Hi

Thanks for the reply. But, if I use the FixWidth property, it’s proportinately increasing the height of the image also. I want to adjust the width of the image based on the values from the database and show it as a horizontal bar chart.

Is there a property called FixHeight? Let us say my image height = 1cm and image width=1 cm. if the database value is 10, i want the image width to be 10, but i want the image height to be constant or please tell me an option to create the attached chart and show it in PDF.

Thanks
Jay

Dear Jay,

Thank you for considering Aspose.

You can use code like the following to resize the image before adding it to pdf:

System.Drawing.Bitmap bm = new System.Drawing.Bitmap(@"D:\Downloads\offline\chart.gif");

System.Drawing.Bitmap bm1 = new System.Drawing.Bitmap(bm,500,100);

bm1.Save(@"D:\Downloads\offline\chart1.gif");

bm1.Dispose();
bm.Dispose();

Hi

Thanks for the option. But I think this may not be a viable option. I have to process the image around 150 times when the user clicks the button to get 150 different sized images of same composed to a chart and created a PDF and download. For this process, it may not be the best.

Do you have any plans to add FixHeight property for image in the future? i.e., without scaling the image.

Thanks
Jay

Dear Jay,

Thank you for considering Aspose.

I have not any plan for supporting this currently but I can consider it when I make new plan.

But I have not really understood why you need such feature. You can easyly create your chart with Aspose.Chart and then add the chart to pdf without any change.

Hello,

This feature would be very useful and save us a lot of time if a FixHeight XML setting could be used. We are planning on having an XML file(template) and swapping out an image at the top of the PDF. If we could have a FixHeight option then we could ensure that an larger image does not push down the rest of the table rows in the PDF and we can have a consistant looking pdf.

Right now I can do this with some manual manipulation on the user's part and using the ScaleImage option, but a FixHeight option would be very useful and save us a lot of time.

Thanks,

Chris.

Dear Chris,

Many customer have asked this feature. I have planed to support it. I hope this feature will be available at March or April.