DocumentBuilder - InsertImage Method doesnot scale an image

Hi,


I am using Aspose words v14.10.0.0, and my doc template has merge fields for images.
All the images except one are scaled properly, for this image the scaling is not being applied but the image is getting displayed and the call back function works as expected.

Can you please help me out with this.

Hi Jasbir,


Thanks for your inquiry.To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document (template) and image file.
  • Aspose.Words generated output document which shows the undesired behavior.
  • Please create a standalone (runnable) simple console application (source code) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with that post by clicking the ‘Add/Update’ button.

Best regards,

Hi Hafeez,


I have attached the sample.
I have taken the aspose sample and modified it to replicate my issue.
Refer “Template Out” file under the data folder. The document contains two images one is properly scaled as expected but the other one is not.

Note that i am using a licensed version for my dev. but the sample doesnot contain one.

Please do disable this link for sample download once you have downloaded the sample.

Thank You

Hi Jasbir,


Thanks for your inquiry. I have corrected the problem in your source code. Please see attached modified “Program.cs” here with this post. I hope, this helps.

Best regards,

Hi Hafeez,


Thanks, the modification works.
But i wanted to know the reason behind using merge only once and using it for each of the sections.
I am asking this because the example i shared with you is only of 2 sections, in real time i can have more.
According to your modification of the code all the images have to be merged first and then we have to merge the table data.

Is there any specific order for these API calls?


Hi Jasbir,

Thanks for your inquiry. You need to separately call both ExecuteWithRegions and Execute methods as they do very different things. Please note that ExecuteWithRegions method fills a region in the document defined by a pair of matching TableStart and TableEnd merge fields with the same table name while the Execute method performs a standard mail merge. Ideally, you should run ExecuteWithRegions first and then run Execute method after it. I hope, this helps.

Best regards,