Hi, I’m trying to do MailMerge that way so the result will be Accessible.
I’ve encounter a problem when working with Images - I need to be able to set AlternativeText for an image and ability to set “Decorative” check on image would be great too. So far I can’t find that option.
I know that Aspose is supporting AltText in some scenarios, I’ve check that I can insert an image with alt text:
DocumentBuilder builder = new DocumentBuilder(originalDoc);
var shape = builder.InsertImage(File.OpenRead("file.jpeg"));
shape.AlternativeText = "something";
and it’s using shape underneath. Now I’d like to do something similar when replacing an image on mail merge. I’ve tried this:
originalDoc.MailMerge.FieldMergingCallback = new HandleMergeImageField();
(...)
public class HandleMergeImageField : IFieldMergingCallback
{
void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)
{
}
void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
{
if (e.FieldName == "Picture")
{
e.Shape = new Shape(e.Document, ShapeType.Image);
e.Shape.ImageData.ImageBytes = File.ReadAllBytes("image.jpeg");
e.Shape.AlternativeText = "something";
}
}
}
but that way I’m ending up with Shape in Word instead of Image. Can you help me with that?
Also, as I’ve mentioned in the begining, ability to set “Decorative” check would be very helpful (of course on other images, then the ones with alt text).
I’m using .NET 7 and Aspose.Words v23.3