HandleMergeImage- how to resize the image

Hello,

I am trying aspose word.
I have a table that shows a list of name and picture for each person.
In my template I have the row height fixed. How can I make the picture to automatically fit the cell dimension?

Thanks

Thank you for your interest in Aspose.Words.
I have attached the demo project which illustrates the technique for doing this. You only need to use MailMerge with regions instead of simple merge used in this demo.
Please let me know if you need further assistance. I will be happy to help
Best regards,

I think that project may be just what I’m looking for, but the forum isn’t letting me access it, it says: "Attachment: Present (inaccessible)".
I’m using Office 2007 creating a doc 97-2003 file and have a table with a merge image field tag. I’m executing a MailMerge.ExecuteWithRegions and for the photo field I have the filename. The photo gets placed in the output document, but it’s cut off, it’s not shrinking down to the size of the cell. I’ve tried some different AutoFit options in Office 2007 to no avail. I know how to resize the image, but I don’t know how to get the size of the cell it’s in (programmatically) so I know what size to resize the image to.

Hi

Thanks for your inquiry. Could you please attach your template, output document and expected output? I will check the issue and provide you more information.
Best regards.

Code, docs, images attached.
I want the image to shrink and fit in the first Cell in the table. Currently the image is in the cell but cut off at the point where it extends outside the cell - I want it to shrink to fit inside the cell.
To do this I need to know how to get the cell width/height that contains the image merge field.

Hi

Thanks for your request. I think you can use MergeImageField event handler to resize your image during mail merge. You can find code example here:
https://forum.aspose.com/t/90293
Hope this helps.
Best regards.

You are correct I can use that event to resize an image, the problem is I don’t know what size to resize it to.
How, at runtime, can I programmatically determine if the image tag is within a table and if it is determine the size of the cell it’s contained within? Once I know that I will know what size to make the image to fit the cell.

Hi

Thanks for your request. You can try to calculate size of container on the fly. I attached code example, which shows the technique, how you can achieve this.
Hope this helps.
Best regards.

I found my problem, sorry.
That’s because I’ve add the event on a DocumentBuilder and next I do a clone and I do the merge on the Clone, so Event was not called.

Thank you for that Cod.txt sample, it was exactly what I was looking for.