I need to implement merging of different Word Fields not just standard Merge Fields.
Specifically - I don’t like using ImageFieldMerging event as it is not “what you see is what you get” - you have a one line paragraph but after merging a picture it can take a whole page or more.
I’d rather prefer getting an event on merging Word’s “Include Picture” Field.
I can then do what ever required to merge a dynamic picture of correct size (while removing original “Incude Picture” Field). I really only need and event passing the field, I think.
Big advantage of “Include Picture” is the fact that include picture tag is shown in Word as a squre which is resizable. I guess if I had an IncludePictureFieldMerging event I could do whatever required there to include a dynamic picture of the same size.
And basically it would help if we could get this event on ANY Word Field (All Word field types one can insert from Insert->Quick Parts->Field in Word 2007) - whatever it is-Formula, Address Block, Advance, AutoNum etc.
OK may be some of them are not applicable/not useful but I bet you that half of them are.
But how about Include Picture for now?
Please?
Hi Graham,
Thanks for your inquiry. Please note that for mail merge operation to work, the document should contain Word MERGEFIELD and optionally NEXT fields. During mail merge operation, merge fields in the document are replaced with values from your data source. This essentially suggests that you can’t use Word’s INCLUDEPICTURE as a replacement to MERGEFIELDs. Moreover, I would suggest you please read the following article on How to Insert Images from a Database:
Also, you can set ImageFieldMerging mail merge handler to be able to control/customize the look of your image. For example:
public void ImageFieldMerging(ImageFieldMergingArgs args)
{
if (args.FieldName.Equals("imgField"))
{
DocumentBuilder builder = new
DocumentBuilder(args.Document);
builder.MoveToMergeField(args.FieldName);
builder.InsertImage(args.FieldValue.ToString(), 200, 200);
}
}
Please let me know if I can be of any further assistance.
Best Regards,
Thanks Awais,
I know about all Aspose features you suggested but it is not good enough for our customers - and I suspect for many other users of Aspose.
This is a new feature request not a question.
When Aspose does merge I want it to call me when it encounters any INCLUDEPICTURE fields (or ideally any field at all).
I do not suggest Aspos does anymerging for me - I will do whatever I want to do,
but I need the event first which will give me the field - that’s all I need to do the rest.
This will allow a lot more flexibility in what can be done using Aspose.
For example user can insert INCLUDEPICTURE and resize it to the size which is appropriate. I can keep a big 3000x3000 picture in DB, scale it down to whatever size user wants it and merge it in. Currently this is Impossible as <> can’t be resized!
Please pass this on to your developers and managers as a feauture request, I am sure they will appreciate the suggestion.
Hi William,
Thanks for your suggestions.
We will gladly consider implementing such behavior, but I think you might find using a different technique much more easier instead of using the INCLUDEPICTURE field. Please see the following link for using a textbox or table cell with a normal merge field to define the size of an image:
The code is all automatic so all you need to do is set the handler before mail merging and it will resize the images automatically.
You can also mail merge into an INCLUDEPICTURE field but you need to use some extra code because of the fact INCLUDEPICTURE is imported into Aspose.Words as a Shape. Please see the following post for an explanation and code:
Thanks Adam - will give it a go and see if I can do what I need.