Image CSS style is ignored and the image is rendered full size in the word using .NET

Hi there
I am experiencing some problem when inserting an html code containing images. The problem ist, that css information like width, height, float are ignored and the final word document always contains an image at 100% of its image size. I suggest its because those params are not part of a custom style (WORD) but params of the image object itself. How can I influence those params anyway?

Deer greetings
Samuel

Hi Samuel,

Thanks for your query. It would be great, If you share your template document and html with images for investigation purposes.

So there are the input and the output file. Theres another question by this: Why does ASpose duplicate each style with a + After: 14pt ?? He does this for every generated style (from InsertHtml in DocumentBuilder).

Dear greetings

Hi Samuel,
Thanks for sharing the files.
The problem occurs because Aspose.Words does not support style attribute on IMG tag. This causes that Aspose.Words does not read size of the image from your source HTML. I linked your request to the appropriate issue. We will let you know once it is resolved.
To work this problem around you can specify size of the image using width and height
attributes of IMG tag instead of using style.

Please use: <img src = 'd: /image.jpg' width="10" height="10"/> instead of: <img src = 'd: /image.jpg' class="Aspose" />
We apologize for your inconvenience.

Hi Tahir
Thanks for the reply. Well thats a work around for the image sizes (while beeing a rather cumbersome one as I will have to parse the html document as well as the css file and the rewriting the html input file for aspse), but its ok. But whats about the floating problem (float:left or float:right)?

Deer greetings
Samuel

Hi Samuel,

It would be great, If you please share some more detail about your following question.

But whats about the floating problem (float:left or float:right)?

The css information float:left and float:right doesn’t take effect since style sheets don’t seem to work with image tags. So I was asking for a workaround, since we have need of this.

Hi Samuel,
Thanks for sharing the information. The workaround of this issue is please use the align property of IMG tag instead of using style.

<img width="100" height="100" align="right" src="" />

We apologize for your inconvenience.

Thank you very much. So there is one last open question:
What is this? Why does he make all format styles twice?

Best regards
Samuel

Hi Samuel,

Thanks for your query. Please remove class=“Aspose” from IMG tag. This imports the styles twice. I already had linked this thread to appropriate issue (WORDSNET-5689). Once this issue is resolved you will not face such issues.

I really appreciate your patience.

When I remove class=“Aspose” from the img tag, then the corresponding style will not be applied to that image anymore. The same remains true for removing the class=“whatever” from p tags. If I have to remove those class definitions, then I IMHO can’t use the format style system anymore at all or am I wrong about this? Is there at least a way to remove those unnecessary format styles?

Best regards
Samuel

Hi Samuel,
Please accept my apologies for misunderstanding. Please remove class="Aspose" from IMG tag and add in <P class="Aspose"> tag as mentioned below. Please let us know, If you have any more queries.

The issues you have found earlier (filed as WORDSNET-5689) have been fixed in this Aspose.Words for .NET 18.12 update and this Aspose.Words for Java 18.12 update.