Insert HTML in Word Document | Scale images based on it's parent absolute size

Hi,

I’m trying to insert a HTML document into a Word document using the following code:

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

The HTML document consists of an image with a style property: max-width: 100%
The image itself is wrapped within a paragraph tag with an absolute width of 50px.

I expect the image to have a width of 50px within the docx file, but the image is rendered full size. Why is this?

Please see the attached files.

Thanks.

files.zip (49,5 KB)

@maartenkelder The behavior is expected, Aspose.Words mimics MS Word behavior. Please note, Aspose.Words is designed to work with MS Word documents. HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one format to another. In most cases Aspose.Words mimics MS Word behavior when work with HTML documents.
If you open your HTML in MS Word you will see exactly the same result.

1 Like