WPCubed Product Support

Scale image in Mail Merge?

In my mail merge template I would like to have a picture of a certain size, say 200x200 pixels. But the images in my data source have varying size, e.g. 300x220, 600x400, etc

Is it possible to have WPTools automatically scale the pictures proportionally when executing the mail merge?

What I already achieved is to offer special mail merge fields e.g. PIC200_200, PIC300_300 and in the code I check which field is currently processed and scale it myself. This can be used for the time being but it has the disadvantage that I have to prepare a number of fields instead of only one and maybe the formats I prepare are not the formats my users want to have.

#1 ♥ 0
3.7k Views 1 links 2 users read 2 min
support

Hi,

If you use the event OnMailMergeGetText event to populate the field (or load the image into the already existing image placeholder) you can precisely scale the image.

Not the function of the TWPOBject class:

Scales contents to width / height (twips). Optionally the contents width and height is used

procedure ScaleWH(w, h: Integer; UseContentsSize: Boolean);

If UseContentsSize=true it will scale according to real size of the image (contents), othewise it will use the current logical W/H ratio.

Julian

#2 ♥ 0

This is also interesting but actually not what I wanted since your solution has to be done at compile time. I need flexibility at run-time instead.

For example, I would like the user of my program to be able to do the following: add a mail merge picture of size 100x100 somewhere in the document. Another user may want to have a picture of size 200x100.

I think what's missing is that the user can define the size of a mail merge field at run-time.

I hope now it's clearer.

#3 ♥ 0
support

Hi,

it was clear and I did not suggest to use a fixed value.

The key is that the merge procedure can update an image placeholder which was already inside the field.

You can use its WidthTW or HeightTW properties to scale the object.

More at this FAQ entry:
[](http://wpcubed.com/forum/viewtopic.php?t=1160)

Julian

#4 ♥ 0
This category is archived. No new posts are possible.