why am i getting e.FieldValue == null in ImageFieldMerging Method?
if I do it in FieldMerging i’m getting a correct value
source is DataTable, doc.MailMerge.Execute(table);
class HandleMergeImageField : IFieldMergingCallback
{
void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)
{
// Do nothing.
if (args.FieldName.EndsWith("_img"))
{
DocumentBuilder _b = new(args.Document);
_b.MoveToMergeField(args.FieldName);
Shape _shape = _b.InsertImage((byte[])args.FieldValue);
_shape.Height = 100;
_shape.Width = 250;
}
}
// /
// / This is called when mail merge engine encounters Image:XXX merge field in the document.
// / You have a chance to return an Image object, file name or a stream that contains the image.
// /
void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
{
MemoryStream stream = (MemoryStream)e.FieldValue;
if (stream!=null)
{
stream.Position = 0;
// Now the mail merge engine will retrieve the image from the stream.
e.ImageStream = stream;
}
}
}