Free Support Forum -

Formatting Images in the Template for Mailmerging purpose


here my Goal:

> Let the customer design their Templates as WYSIWYG as possible. That means Load and Show an Image as “Image:XXX” Field, let the customer format that Image (Border, Size …).

> Mailmerge with Aspose.Word should then substitute the Image:XXX fields with Images from a specified Data Source.

- This all works fine, but all format done on the Image (as Placeholder) is lost and the inserted Picture has simply no Format information.

Do you have any suggestion on how to keep (or read and rewrite) the Placeholders format information ?

Onea Application of this Idea is to load Big Images and show in a table only Thumbnails by scaling the Images.



Would you be so kind to elaborate your question? In what way are you applying formatting to images so it is lost? Are you performing this manually in the document? If so, please attach your document template and describe what is wrong there.

Thank you for the request.

Hi Dmitry,

what I mean is, in the document template there is a mergefield of type image. I use a placeholder image in Word so that I can apply some formatting, eg border style, colour, textflow, etc. Unfortunately, when I run this through the mailmerge operation, the substituted image does not retain the formatting I applied.

Please find the document template attached, with the mentioned image field.



Now it's clear. The point is that if you need to apply some formatting to the image being inserted into a template, using another image as a placeholder just won't work. You should use another way. Instead of passing an image object or file name to the event args, implement DocumentBuilder inside the merge handler, move the cursor to the merge field and insert the image using one of DocumentBuilder.InsertImage overloads that allow to specify many image formatting parameters.