Forum


Replies: 1   Views: 414
Embedhtml with a table - if content of table is too long, it will make the column too wide.
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by ralfjahr  · 26-01-2023 - 14:59

Hello,

We are rendering a table with several columns. If the content of one of these cells is a very long URL, it will take as much space as it can get, then finally "break" the URL and move the rest to the next line.

https://imgur.com/a/pqEDTK5

We are setting the column width as follows, basically setting it to a fixed pt value so that it works in docx and libreoffice-pdf:

<td width="{{ (letterWidthPt * 0.10) | round }}pt">

Thanks for helping us!

Ralf

PS: In regular HTML it would be the following but I cannot see that this works:

/** Verhindert, das Zellen zu lang werden */
.dont-break-out {

    /* These are technically the same, but use both */
    overflow-wrap: break-word;
    word-wrap: break-word;

    -ms-word-break: break-all;
    /* This is the dangerous one in WebKit, as it breaks things wherever */
    word-break: break-all;
    /* Instead use this non-standard one: */
    word-break: break-word;

    /* Adds a hyphen where the word breaks, if supported (No Blink) */
    -ms-hyphens: auto;
    -moz-hyphens: auto;
    -webkit-hyphens: auto;
    hyphens: auto;

}

 

Posted by admin  · 26-01-2023 - 15:18

Hello,

That's the default behaviour of MS Word. Although you can apply fixed widths to cells, if a string is very long without spaces, then the cell width will be increased automatically.

The addTable method includes the fitText option that can be applied to cells:

fitText   bool   If true fits the text to the size of the cell.

But this option is not available when transforming HTML. We have added a task to add support in the next release of phpdocx (there's no release date).

Regards.