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