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);
}