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

Free Support Forum - aspose.com

Issue while inserting html table at a bookmark

Hi ,

I am using Aspose.words for java 3.2.0. I am trying to insert HTML table at a bookmark position. I am trying to set width and align = “center” to

. I got different results when I use style attribute of and with width and align attributes of .

I have tested with the below code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

String html = "

First Table

"
+ " <table border=1 width = “500px”>
"
+ "
"
+ " <td align=“center” width=“250px”>First Column
"
+ " <td width=“250px”>Second Column
"
+ "
"
+ "


"


+ "

Second Table

"
+ " <table border=1 width = “500px”>
"
+ "
"
+ " <td align=“center” style=“width:250px;”>First Column
"
+ " <td style=“width:250px;”>Second Column
"
+ "
"
+ "


"


+ "

Third Table

"
+ " <table border=1 width = “500px”>
"
+ "
"
+ " <td width=“250px” style=“text-align:center;”>First Column
"
+ " <td width=“250px”>Second Column
"
+ "
"
+ "


"


+ "

Fourth Table

"
+ " <table border=1 width = “500px”>
"
+ "
"
+ " <td style=“width:250px; text-align:center;”>First Column
"
+ " <td style=“width:250px;”>Second Column
"
+ "
"
+ "


";

builder.insertHtml(html);

doc.save(“C:\Temp\out.doc”, SaveFormat.DOC);


Attached the out.doc for your reference.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I see only two problems here.

1. In your HTML you specified width via TD attribute improperly. Due to HTML specification width attribute may be either a %Pixel; or a percentage of the available horizontal or vertical space. So you cannot specify measurement units in width attribute. Your HTML should look like the following:

String html = "

First Table

"

+ " <table border=1 width = \"500\">
"

+ "
"

+ " <td align=\"center\" width=\"250\">First Column
"

+ " <td width=\"250\">Second Column
"

+ "


"

+ "


"

2. Problem with alignment, when you specify it using style attributes. This occurs because currently, Aspose.Words does not support inheriting styles from parent elements. I linked your request to the appropriate issue. You will be notified as soon as it is resolved.

Best regards,

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


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