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

Free Support Forum - aspose.com

Aspose.Words.DocumentBuilder.InsertImage disposing the image?

We’re using the DocumentBuilder…

public Shape InsertImage(Image image, double width, double height);

… method. We’re finding after calling the InsertImage method the Bitmap object passed to it seems to getting disposed, accessing the Width or Height properties on the Bitmap throwing an exception…

System.ArgumentException: Parameter is not valid.

Stack Trace: 
Image.get_Height()

Is this the expected behaviour?
Does the InsertImage call dispose on the image object passed to it?
Do we need to reload the Bitmap object after every time we call InsertImage?
The code we have looks something like…

if (locationLogo != null && locationLogo.Height > 0 && locationLogo.Width > 0)
{
    double height = ConvertUtil.PointToPixel(headerPointHeight + 1);
    double width = docBuilder.CellFormat.Width;
    if (height / width > locationLogo.Height / locationLogo.Width)
        width = locationLogo.Width * height / locationLogo.Height;
    else
        height = locationLogo.Height * width / locationLogo.Width;

    docBuilder.InsertImage(locationLogo, width, height);
}

It seems to be specific to certain JPGs…

SHL-GER-MLHB-220428180752.jpg (148.3 KB)

@support-1
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25166

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.