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

Free Support Forum - aspose.com

Having problem resizing the output image from pdf

I am taking a pdf converting it to an image.

The problem is, that I want to resize the image and it won't resize.

I am using this code:

pdfConverter.GetNextImage(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg, 100,100, 50);

Now, the last param will work..it reduced image quality, but the 100 and 100 do not take any effect at all. I cannot get anything other than the default size.

What am I missing. I am using the latest version of the .dlls already.

Hi Mike,

You are calling an overload that accepts image resolution integer parameter.

If you are going to change image size, please call the overload that accepts float parameters:

pdfConverter.GetNextImage(outFile, System.Drawing.Imaging.ImageFormat.Jpeg, (float)100, (float)100, 100)

Aha! Such a simple oversight by me. Thanks. That resized the image.
Followup question.

Is there a way to do this as a "percentage" instead of a fixed amout? Say, I don't know the original size, but would like it to be 50% of original. Is there a way to find out the outputted size first, then maybe do some math (assuming a pct doesn't work)?

Here is how I resolved the "percentage" problem for anyone out there that needs this info.

I set a "zoomsize" variable" and multiply it against the original height produced by aspose pdf-image convert.

MemoryStream ms = new MemoryStream();

if (pdfConverter.HasNextImage())


pdfConverter.GetNextImage(ms, System.Drawing.Imaging.ImageFormat.Png);



System.Drawing.Image image = System.Drawing.Image.FromStream(ms);

Bitmap result = new Bitmap(Convert.ToInt32(Math.Round(image.Width * zoomSize, 0)), Convert.ToInt32(Math.Round(image.Height * zoomSize)));

//use a graphics object to draw the resized image into the bitmap

using (Graphics graphics = Graphics.FromImage(result))


graphics.DrawImage(image, 0, 0, result.Width, result.Height);





result.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);

Hi Mike,

We’re glad to know that you have worked it out. If you need any further assistance from our end, please do let us know.