We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Insert HTML in Word Document | Scale Images with Widths in Percentage Relative to Cell | C# .NET

We have HTML that contains a table (styled to 100% width) with 10 cells, each cell contians an image with a 100% width style. Each image is 100px wide. When using DocumentBuilder.InsertHTML() the images are rendered at original width causing the table to go beyond the edge of the page. Where as the HTML viewed in a browser limits the table to 100% width and forces the images to occupy 100% of the available space within each cell, effectivly about 50% reduction in original image size.

I know that this mimics the behaviour of opening the same HTML in MS Word but is there a generic way around this (this is one of numerous tables containing images)? I have tried to detect the size of the parent container of the Shape object but this is set to the over size as the image is already rendered within the cell causing it to have the same size as the original image.

Sample .NET Code:

var doc = new Document();
var builder = new DocumentBuilder(doc);
doc.Save("Test.docx", SaveFormat.Docx);



Please compress the following resources into ZIP format and attach the .zip file here for testing:

  • A simplified HTML file containing the Table with Images
  • Aspose.Words generated output DOCX document showing the undesired behavior
  • Your expected Word file showing the desired output. You can create this file manually by using MS Word or any other editor.

As soon as you get these pieces of information ready, we will then start further investigation into your scenario and provide you more information.

Hi Awais,
Attached is a zip with the files you requested.

ImageSizeIssue.zip (391.8 KB)


We have logged your requirement/problem in our issue tracking system. Your ticket number is WORDSNET-22320. We will further look into the details of this issue and will keep you updated here on the status of the linked ticket. We apologize for any inconvenience.