function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
liron169liron169 

Problem with columns width in table

I'm using VF page as PDF, and showing some data in tables.

The problem is that if text field that inside the table have no spaces than the column exapnd more than the width.

 

I create example that show the problem.

Is there any easy way to solve it?

 

 

Best Answer chosen by Admin (Salesforce Developers) 
liron169liron169

I found a solution in HTML forum.

need to use preprty word-wrap:break-word;

This way the line will break also if it doesn't have spaces

 

<html>
<table width="200" border="1" style="table-layout: fixed;">
            <tr>
                <td style="width:100px; word-wrap:break-word;">
                    This is long line so it should break
                </td>

                <td style="width:100px; word-wrap:break-word;">
                    This_is_also_long_line_but_it_without_spaces
                </td>
            </tr>
    </table>
</html>

 

All Answers

harsha__charsha__c

Did you try giving width for "td" through style attribute?

liron169liron169

I try it now, and the result is the same

harsha__charsha__c

You specified width in which parameters?

 

I mean px/em/....?

liron169liron169

I'm writing:

 

<td style="width:100px">

liron169liron169
Just to update,
This is HTML issue, not specifically for SF.
According to answer that I get, the only way to break the line without spaces is with java script.
Sunny670Sunny670
Also set the width for your table to a fixed value and the divide the available width to number of columns. So that you can prevent it.
liron169liron169

I found a solution in HTML forum.

need to use preprty word-wrap:break-word;

This way the line will break also if it doesn't have spaces

 

<html>
<table width="200" border="1" style="table-layout: fixed;">
            <tr>
                <td style="width:100px; word-wrap:break-word;">
                    This is long line so it should break
                </td>

                <td style="width:100px; word-wrap:break-word;">
                    This_is_also_long_line_but_it_without_spaces
                </td>
            </tr>
    </table>
</html>

 

This was selected as the best answer