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

Free Support Forum - aspose.com

Table Indention wrong when table with cellpadding inserted from HTML

Dear support-Team,

we’re inserting tables from HTML into Aspose Words Java.
The table we’re inserting has a cellpadding set to some value.

The result in the word document is that the whole table gets indented - in addition to the applied cell margins.

Please use this code to reproduce:

import com.aspose.words.DocumentBuilder;
import com.aspose.words.OoxmlSaveOptions;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class AsposeTest {
    public static void main(String[] args) {
        try {
            File file =  File.createTempFile("tempFile",".docx");
            FileOutputStream openOutputStream = FileUtils.openOutputStream(file);
            DocumentBuilder documentBuilder = new DocumentBuilder();
            documentBuilder.insertHtml("<table style=\"border: 0 solid #b4b4b4; bordercollapse: collapse; border-color: #b4b4b4; border-style: solid;\" border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"50\"><tbody><tr><td>Lorem ipsum&nbsp;</td></tr></tbody></table>");
            documentBuilder.getDocument().save(openOutputStream, new OoxmlSaveOptions());
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Our expectation would be that:

  • The table padding should be applied according to the value in cellpadding attribute in HTML
  • The table indent should NOT be applied

The problem can be reproduced in the most recent version of Aspose Words for Java 19.10

Thanks for your support

@orgavision,

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