Mail merge picture size using Gembox Document

by Nicolas C   Last Updated June 30, 2020 02:26 AM

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…


Answers 1

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.

Mario Z
Mario Z
June 30, 2020 02:25 AM

Related Questions

Edit form controls with GemBox.Document

Updated July 09, 2017 14:26 PM

Reading Excel File with Gembox - Columns.Count = 0

Updated October 08, 2019 05:26 AM

Block document.write on webview (popup)?

Updated March 10, 2017 07:26 AM