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

Free Support Forum - aspose.com

Image problem migrating to Aspose.Words

We are upgrading from Aspose.Word to Aspose.Words Everything in my code works except merging image fields: I have tried several ways (setting e.Image, e.ImageStream. e.ImageFilename, inserting image via DucumentBuilder), and the image is never merged.

It seems that the problem is the format in which we store images in database, because if I convert the image to a different format - jpg, for instance- with “image.Save(stream, Format.ImageFormat.Jpeg)”, then the merge works… However, I have saved the original image to disk, and MS Word can read it without problems.

My problem is solved by the moment with this jpg conversion, but it would be great if you could tell me more about it… Here is the code where we store images in database:

Bitmap img = (Bitmap)pictureBox.Image;
MemoryStream ms = new MemoryStream();
byte[] bs = new byte[ms.Length];
//bs is stored in database

I also attach a sample image

Thank you!

There are some problems with image format, because when I try to insert it to a document using DocumentBuilder it gives "Out of memory" exception. Maybe it is due to the fact that BMP image is 32-bit color. I have logged this problem to our defect base as issue #1505. We will try to fix it as fast as we can. Meanwhile, please use the conversion workaround that you are already using. Only it is better to use PNG format instead of JPG as PNG is lossless, and JPG actually affects image quality.

Best regards,

The issues you have found earlier (filed as 1505) have been fixed in this update.