HTML Table Cell Padding ignored when inserted into Document

Hi Team,

I am trying to retain the HTML formatting applied on Table Cells by inserting the HTML content within the Document object as follows but the issue occurs within the Table Cell which does not honor the cell style “padding-left” value “12px” or “9pt” when it is rendered in the Word Document.

bytes[] html = Files.readAllBytes(Paths.get("TableWithCellPadding.html"));
HtmlLoadOptions options = new HtmlLoadOptions();
Document wdDoc = new Document(html, options);
wDoc.save("TableWithCellPadding.docx");

Environment Details:

  • Aspose Words for Java 21.7
  • Java version 1.8.0_211
  • Windows 11 (but also reproducible under Linux).

File Attachment Sample Test Case 1 - Table Cell Padding Missing.zip (20.7 KB)

How to fix the table cell padding-left problem? I have attached the expected output Word document.

@oraspose
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26235

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@alexey.noskov Thanks for the confirmation and opening a new ticket. We will monitor this thread closely.

1 Like

@oraspose We have completed the analysis of the issue and concluded this is not a bug but rather a limitation of Aspose.Words’ document model.

In the source HTML document, padding is applied to inline-level <span> elements:

<style>
    .gcepadl12{padding-left:12px;}
</style>
<!-- ... -->
<tr id="rr2" style="top:50.0px;">
    <th id=cc0 class=" crp0">
        <span class='gcOff gcepadl12'>Account:&nbsp;Income&nbsp;Statement,&nbsp;Year:&nbsp;2013</span>
    </th>
    <th id=cc1 class=" crp0">xentity</th>
    <td id=cc2 class=" crp3">27,359,937</td>
</tr>

Such formatting is not supported by Aspose.Words’ document model, because its inline-level run nodes cannot have any padding. As a result, “padding” styles on <span> elements are ignored during conversion.

So, the observed behavior is expected and we are not going to add support for “padding” on inline-level spans. The issue will be closed as not a bug.

The issues you have found earlier (filed as WORDSNET-26235) have been fixed in this Aspose.Words for Java 23.12 update.

@alexey.noskov Is this issue fixed? I thought you mentioned that this is ASPOSE Words limitation in your latest comment.

Could you confirm which is correct?

@oraspose This is an automatic notification. The issue has been closed as Not a Bug.

Thanks for the confirmation.

1 Like