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 <td>
. I got different results when I use style attribute of <td>
and with width and align attributes of <td>
.
I have tested with the below code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
String html = " <h1> First Table </h1> "
+ " <table border=1 width=\"500px\">"
+ " <tr>"
+ " <td align=\"center\" width=\"250px\"><strong>First Column</strong></td> "
+ " <td width=\"250px\"><strong>Second Column</strong></td> "
+ " </tr>"
+ " </table>"
+ " <h1> Second Table </h1> "
+ " <table border=1 width=\"500px\"> "
+ " <tr>"
+ " <td align=\"center\" style=\"width:250px;\"><strong>First Column</strong></td> "
+ " <td style=\"width:250px;\"><strong>Second Column</strong></td> "
+ " </tr>"
+ " </table> "
+ " <h1> Third Table </h1> "
+ " <table border=1 width=\"500px\"> "
+ " <tr>"
+ " <td width=\"250px\" style=\"text-align:center;\"><strong>First Column</strong></td> "
+ " <td width=\"250px\"><strong>Second Column</strong></td> "
+ " </tr>"
+ " </table> "
+ " <h1> Fourth Table </h1> "
+ " <table border=1 width=\"500px\"> "
+ " <tr>"
+ " <td style=\"width:250px; text-align:center;\"><strong>First Column</strong></td> "
+ " <td style=\"width:250px;\"><strong>Second Column</strong></td> "
+ " </tr>"
+ " </table> ";
builder.insertHtml(html);
doc.save("C:\\Temp\\out.doc", SaveFormat.DOC);
Attached the out.doc for your reference.