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

Free Support Forum - aspose.com

Cannot get Maximum height of Image

Hi,
I Just convert word document pages as a single Image...

Suppose the height of the images is maximun it throw th error..
Here is my code

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Jpeg);
options.PageIndex = 0;
options.PageCount = doc.PageCount;
options.Resolution = 300;
for (int i = 0; i < doc.PageCount; i++)
{
options.PageIndex = i;

using (MemoryStream imgStream = new MemoryStream())
{
doc.Save(imgStream, options);
imgStream.Position = 0;
using (Bitmap bmp = new Bitmap(imgStream))
{
images.Add(new Bitmap(imgStream));
bigImageWidth = (bigImageWidth < bmp.Width) ? bmp.Width : bigImageWidth;
bigImageHeight += bmp.Height;
}
imgStream.Close();
}

}
// Errors throws here.. To avoid this, I just Insert condition with some message
if (bigImageHeight >= 17540)
{
throw new Exception("Image size is too large. Select only one article to get image....!");
}
using (Bitmap bigImage = new Bitmap(bigImageWidth, bigImageHeight))
{
using (Graphics gfx = Graphics.FromImage(bigImage))
{
//set background color
gfx.Clear(Color.Black);
//go through each image and draw it on the final image
int offset = 0;
int i = 0;
// images = null;
foreach (Bitmap image in images)
{
i++;
gfx.DrawImage(image, new Rectangle(0, offset, image.Width, image.Height));
offset += image.Height;
}
}
MemoryStream memoryStream = new MemoryStream();
bigImage.Save(memoryStream, ImageFormat.Jpeg);





if the images Height is 17540, it throw the error "Parameter is not valid"
Pls tell me the solutions to avoid this problem..



Thanks,
Narendran
Hi Narendran,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.