Image in Word during mailmerger

Hi,


I am converting an image which is built during runtime to an ImageStream,

Stream Image_stream = new MemoryStream();

doc.MailMerge.FieldMergingCallback = new HandleImageMerging(Image_stream);

private class HandleImageMerging : IFieldMergingCallback
{
private Stream xImages;

public HandleImageMerging(Stream iStream)
{
xImages = iStream;
}

public void ImageFieldMerging(ImageFieldMergingArgs e)
{
if (e.FieldName.Equals(“PictureFileName”))
{
e.ImageStream = xImages;
}
}

public void FieldMerging(FieldMergingArgs e)
{
}

}


My Problem is that word document that is produced displays the image which appears to be not visible. Upon clicking randomly near the image mergefield location a dotted picture box appears in that place. On going into the picture box properties and setting the Layout text wrapping to “Square” the image becomes visible. How do i control this layout from code also how do i make sure the image fits in the table cell where the image mergefield is present.

Hi Varun,

Thanks for your inquiry.

Could you please save the stream directly to disk and attach the data along with your template and we will investigate this further for you.

Thanks,

Ran into this old post i had posted while searching for something else :slight_smile: . The problem I was facing was fixed by changing the Paragraph Line spacing to Single. If the Paragraph Line Spacing is set to “Exactly” the image will appear to be hidden.

Hi Varun,


Thanks for following up with this thread.

It’s great you worked out the problem. Feel free to ask us any time you need any help.

Thanks,