列文本超出列宽 [英] Column text overflowing out of column width

查看:47
本文介绍了列文本超出列宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Migradoc 生成一个表并为几列填充一些动态数据,我在定义表结构的同时定义了列宽 -

I am using Migradoc to generate a table and populating some dynamic data for few columns, I have defined column width while defining table structure as-

Table table = new Table();
Column column = table.AddColumn(Unit.FromCentimeter(6));
column.Format.Alignment = ParagraphAlignment.Left;
table.AddColumn(Unit.FromCentimeter(6));
table.AddColumn(Unit.FromCentimeter(8));

现在第三列有数据 (acs800-07-1234a-5+asdf+asdf+qwer+wert+2345+rg+2345+ag+35+qwe1252rg+34tgh+24rg+253rg+23rgh+235rgh+@34gh+23rg-4s544) ,但它溢出了列并被截断到页面的右侧.它会自动换行但不正确,某些文本在第二行丢失了.查看图片:

Now the third column is having data (acs800-07-1234a-5+asdf+asdf+qwer+wert+2345+rg+2345+ag+35+qwe1252rg+34tgh+24rg+253rg+23rgh+235rgh+@34gh+23rg-4s544) , but it's overflowing the column and getting truncated towards the right side of page. It's automatically wrapped but not correctly , some text is lost in the second line. See image:

任何在换行文本中解决此问题的指针将不胜感激.

Any pointers to fix this issue in wrapping text would be appreciated.

UPDATE-(显示如何添加表格数据的片段)

UPDATE- ( Snippet showing how table data is added)

Row row = table.AddRow();
Cell cell = row.Cells[0];
cell.AddParagraph("ACS880-104");
cell = row.Cells[1];
cell.AddParagraph("R1 – R10");
cell = row.Cells[2];            
cell.AddParagraph("acs800-07-1234a-5+asdf+asdf+qwer+wert+2345+rg+2345+ag+35+qwe+125+2rg+34tgh+24rg+253rg+23rgh+235rgh+@34gh+23rg-4s544");

推荐答案

MigraDoc 自动在空格、连字符和软连字符处换行.

MigraDoc automatically breaks lines at spaces, hyphens, and soft hyphens.

您有一个没有空格和连字符的长文本.简单的解决方案:在您希望出现换行符的地方插入软连字符(例如,在每个+"号之后添加一个软连字符).

You have a long text without spaces and without hyphens. The easy solution: insert soft hyphens where you want to allow line breaks to occur (e.g. a soft hyphen after each "+" sign).

更新:从 1.50 版开始,您还可以使用零宽度非连接符来标记允许换行的位置.使用软连字符获取带连字符的换行符,使用零宽度非连接符表示不带连字符的换行符.

Update: As of version 1.50 you can also use zero-width non-joiners to mark locations where line breaks are allowed. Use soft hyphens to get line breaks with a hyphen, use zero-width non-joiners for line breaks without hyphens.

这篇关于列文本超出列宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆