builder.InsertHtml(); formatting problem

We are having trouble setting width of embedded image and setting width of table
I have attached html and word file

The code for inserting html is below

string sHtml = sw.ToString();

Document doc = new Document();
// Once the builder is created, its cursor is positioned at the beginning of the document.
DocumentBuilder builder = new DocumentBuilder(doc);
builder.PageSetup.Orientation = Aspose.Words.Orientation.Landscape;
builder.PageSetup.TopMargin = 5;
builder.PageSetup.LeftMargin = 8;
builder.PageSetup.BottomMargin = 5;
builder.PageSetup.RightMargin = 8;
builder.InsertHtml((string) sHtml);

Please let me know how can we maintain the width of table and image

Hi Asif,
Thanks for your inquiry. The embedded images in shared HTML use the ‘style’ attribute. Unfortunately, ‘style’ attribute of ‘img’ tag is not yet supported by Aspose.Words. We had already logged this feature request as WORDSNET-2020 in our issue tracking system. You will be notified via this forum thread once this feature is available.

Please use width and height properties of IMG tag as shown below in your html.

<img width="400" height="400" src="test.jpg">

We apologize for your inconvenience.

Thanks for your reply how ever the code did not work , I had tried this, earlier as well tried again but no luck. I have attached the img2.html please check that

Hi Asif,
Thanks for your inquiry. Please use width and height properties of IMG tag as shown below in your html.

<img width="500" height="250" src="....">

I have modified the shared HTML IMG tag (width=“500” height=“250”). Please find the modified HTML and output Docx file in attachment.
Please let us know if you have any more queries.

Hi ,

Thanks for your reply , so you mean “px” or “in” units should not be mentioned in the attributes ?

I tried removing units and just kept number it worked , does this apply for other objects in the html as well , to work with asposewords insertHtml() ?

Thanks

Hi Asif,

Thanks for your inquiry. When you specify size of an image using width and height attributes, you should not specify measurement units like px, in etc. You can use ‘Style’ attribute with HTML tag as shown below.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml("Your HTML");

Please read following articles for your kind reference (document features supported on HTML import and export).
https://docs.aspose.com/words/net/document-features-supported-on-html-import/
https://docs.aspose.com/words/net/document-features-supported-on-html-export/

The issues you have found earlier (filed as WORDSNET-2020) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(27)