We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Controlling Image Size & Position in Mail Merge

During a mail merge within Aspose.Words is there any way to control the size, position and other properties of the image inserted?

In my old method of mail merging, I would include a clear image in the template and all the properties could be set and then copied over to the image being inserted.

The most popular method to insert image during MailMerge is DocumentBuilder.InsertImage. It has a number of overloads where you can control image size, wrapping and positioning. The method returns the shape object. This shape object can be used to control size, positioning and wrapping after the insertion. For this you can use Shape.Width, Shape.Height, Shap.ImageData and other properties.

Hope this helps. If you have further questions please provide the template example and your old code. Then, I can give further instructions on how to handle this task.

Best regards,

I realized that there is a way to insert an image and control these properties, however I am doing the image as part of the Mail Merge process using a <> merge field. Even if I did a regular merge field and then used the event to manually insert the image, where would the user creating the template specify those properties (size, position)?

You referred that you used some "older method of mail merging". Please describe it in a more detailed form and we will try to develop something similar. Also, sample template document illustrating your point will be very helpful.

This older method was PRE-Aspose, but it involved doing a Search of all images / shape objects in the section and copying all properties from the found placeholder image to the newly inserted image before deleting the placeholder.

Attached is a sample project where I have attempted to replicate you old approach as you have described it. Please let me know if you will have any further questions after reviewing it.

Best regards,

I am wondering about the same functionality and it says your attachment is inaccessable to me. Can you please post some sample code again?

Thanks,

Eric

Hi



I have attached this sample application for you again.



Best regards.

<o:p></o:p>

Thanks,

Eric

So this looks great so far but what I have is this:

Aspose.Words.InlineShape inlineShape = _Builder.InsertImage(path);

inlineShape.Height = aHeight;

inlineShape.Width = aWidth;

This may seem like a noob question for you but now how can i also set top and left for placemen? Also how do I set my image to front of text instead of inline with text?

TIA,

Eric

EDIT: After thinking about it, I should let you know I am on Aspose.Words Version 3.7.1.0... maybe the functionality is not in this older version...

EDIT: Never mind on all the above... I used one of the overloads for InsertImage and got everything I needed... Thanks

Hi

It is very nice that you found solution independently.


Best regards.