I’m using the mailmerge feature of Gembox.Document to produce reports. I’m having issues with the sizing of a picture.
I have created a merge field inside a table cell, and I would like the picture to occupy the maximum of the cell size without changing it’s aspect ratio.
For now it’s inserting the picture, but the ratio is all messed up.
I’ve read in the help page that I could put a shape my merge field but after many attempts I don’t know how to do it, when I try to draw the shape in my word template, it doesn’t go inside my merge field.
Can anybody help me with this ? Either to fix the aspect ratio, or how to use the shape…
Cheers
Take a look at the second Merge Pictures example, its input "MergePicturesWithTemplates.docx" file has MergeFields
with Shapes
inside.
To place a Shape
inside a MergeField
, draw the shape, set it as "In Line with Text", and drag it inside the field.
Now that you have a shape as a placeholder for your image, you can add switches to MergeField in order to keep the aspect ratio of the merged picture:
\x
- resize resulting picture horizontally, keep the template shape's height.\y
- resize resulting picture vertically, keep the template shape's width.\x \y
- resize resulting picture either horizontally or vertically.To add a switch, press ALT + F9 in MS Word, that will reveal field's code and then write the switch within.