Table width export problem

Hello, I have a problem with exporting tables. I have an HTML table

<table style="border-collapse: collapse; width: 100%;" border="1">
  <colgroup>
    <col style="width: 10.4519%;">
    <col style="width: 46.2021%;">
    <col style="width: 42.9953%;">
    <col style="width: 0.356314%;">
  </colgroup>\n <tbody>\n <tr>\n <td>Текст</td>\n <td>Текст</td>\n <td>Текст</td>\n <td>
        <br>
      </td>\n </tr>\n <tr>\n <td>
        <span>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit </span>
      </td>\n <td>\n <ol>\n <li>еукукеукеукеу</li>\n <li>еукеукеу\n <ol>\n <li>гопеопнопне\n <ol>\n <li>&nbsp;еукеуеуке\n <ol>\n <li>&nbsp;ппкенрекнке\n <ol>\n <li>нраосопсо&nbsp;\n <ol>\n <li>екгекгкегвкнгдпрш\n <ol>\n <li>&nbsp;87686868\n <ol>\n <li>9097090-\n <ol>\n <li>0980890\n <ol>\n <li>897897978979789797\n <ol>\n <li>8678678678678</li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </li>\n </ol>\n </td>\n <td>
        <span>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit </span>
      </td>\n <td>
        <span>Sed ut perspiciatis unde </span>
      </td>\n </tr>\n <tr>\n <td>
        <span>Sed ut perspiciatis  sit </span>
      </td>\n <td>
        <span>Sed ut perspiciatis  </span>
      </td>\n <td>
        <span>Sed ut perspiciatis  </span>
      </td>\n <td>
        <span>
          <br>
        </span>
      </td>\n </tr>\n </tbody>\n
</table> 

I want it look like this after exporting do MS Word:

But it looks like this:

How can I fit it to list depending on this values?

<colgroup>
    <col style="width: 10.4519%;">
    <col style="width: 46.2021%;">
    <col style="width: 42.9953%;">
    <col style="width: 0.356314%;">
</colgroup>

@cagecrew You should note, however, that HTML documents and MS Word documents object models are quite different and it is not always possible to provide 100% fidelity after conversion one format to another.
In your case there should be enough space on the page:

Document doc = new Document("C:\\Temp\\in.html");
doc.getFirstSection().getPageSetup().setPaperSize(PaperSize.A3);
doc.getFirstSection().getPageSetup().setOrientation(Orientation.LANDSCAPE);
doc.save("C:\\Temp\\out.docx");

out.docx (9.6 KB)

Thanks, but I want this table fit to standard A4 sheet with Portrait Orientation.

Is it possible for a table to be created with these parameters and fit into a regular sheet?

<cogroup>
    <col style="width: 10.4519%;">
    <col style="width: 46.2021%;">
    <col style="width: 42.9953%;">
    <col style="width: 0.356314%;">
</colgroup>

So that the width of the table from border to border is 100%, and the width of the columns is set depending on cogroup values

@cagecrew In your case content simply cannot be fit to A4 page size. You can try resetting left intent in the second column to get the result closer to expected.

1 Like

table.setLeftIndent(0); - working very good! Thank you)

1 Like