Unexpected Column Widths after HTML with Merged Cells is Converted to DOCX

Hello,

We are seeing an issue related to HTML that contains a table with merged cells in the last columns. When the HTML is added to a document, the column widths of the imported table are not consistent with the widths specified in the source HTML.

This behavior can be seen in the latest Aspose Words for Java version 21.9, the attached LastColsMerged.html file and the following Java code:

final String htmlSrc = [PATH] + "LastColsMerged.html";

// create a new Document and DocumentBuilder
Document wdDoc = new Document();
DocumentBuilder builder = new DocumentBuilder(wdDoc);
builder.moveToDocumentEnd();

// load and insert the SVG source into the doc
String html = new String(Files.readAllBytes(Paths.get(htmlSrc)), "UTF-8");
builder.insertHtml(html, false);

final String newDoc = htmlSrc.replace(".html", ".docx");
Files.deleteIfExists(Paths.get(newDoc));
wdDoc.save(newDoc);
System.out.println("Saved Word Document:  " + newDoc);

Running the above code should produce the attached LastColsMerged.docx file.

Key Observations:

  • Opening the LastColsMerged.html file in a Browser (such as Firefox or Edge) - shows the expected column widths.
  • Opening the generated LastColsMerged.docx file in MS Word shows the table columns different than the Browser.
  • It seems that the width of the 4th column is being inherited by the 1st column.
  • Some of the row heights have also been increased to accommodate the text from the last two columns.
  • We also tried disabling the Table.AllowAutoFit property after the import, but this produced the same results.

Environment Details:

  • Aspose Words for Java 21.9
  • Java version 1.8.0_211
  • Windows 10 OS (but also reproducible under Linux).

File description in the LastColsMerged.zip (8.2 KB) attachment:

  • LastColsMerged.html: Source HTML file used by the code aboveā€¦
  • LastColsMerged.docx: Aspose generated DOCX file after running the code above on our environment.

Thank you!

@oraspose,

We tested the scenario and have managed to reproduce the same behavior on our end. For the sake of correction, we have logged this problem in our issue tracking system. Your ticket number is WORDSNET-22835. We will further look into the details of this problem and will keep you updated here on the status of correction. We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-22835) have been fixed in this Aspose.Words for Java 22.5 update also available on Maven.