如何解决表单元格中的C#iText长段重叠
我在C#上使用IText版本7。我正在将system.data.DataTable添加到iText.Layout.Element.Table。
我的挑战是,当单元格中的段落很长时,段落的第二行与第一行“重叠”。 我尝试将段落高度设置为12。但是仍然失败。我可以知道如何解决这个问题吗?
public void AddByTable(DataTable dbResult)
{
float[] columnWidths = { 25,3,3 };
Table table = new Table(UnitValue.CreatePercentArray(columnWidths)).UseAllAvailableWidth();
//add header
table.AddCell(_AddNewParagraph("Desc",padding: 1)) ;
table.AddCell(_AddNewParagraph("DO",padding: 1));
table.AddCell(_AddNewParagraph("Rec",padding: 1));
table.AddCell(_AddNewParagraph("Var",padding: 1));
table.SetKeepWithNext(true);
var strItemDesc="";
foreach (DaTarow row in dbResult.Rows)
{
strItemDesc = row["vch_desc"].ToString();
//table.AddCell(_AddNewParagraph(strItemDesc,padding: 1,fontSize:6));
//table.AddCell(
// new Paragraph(strItemDesc)
// .SetFixedLeading(2.0f)
// .SetFont(_font)
// .SetFontSize(6)
// .SetPadding(1)
// );
Cell c= new Cell();
c.Add(
new Paragraph(strItemDesc)
.SetFixedLeading(2.0f)
.SetFont(_font)
.SetFontSize(6)
.SetPadding(1)
.SetHeight(12) //this height did no solve the overflow problem.
);
table.AddCell(c) ;
table.AddCell(_AddNewParagraph(row["DOQty"].ToString(),fontSize: 6));
table.AddCell(_AddNewParagraph(row["RcvQty"].ToString(),fontSize: 6));
table.AddCell(_AddNewParagraph(row["VAR"].ToString(),fontSize: 6));
}
_doc.Add(table);
}
解决方法
您使用
.SetFixedLeading(2.0f)
确切要求您看到的行为。如果您不希望重叠的线,请不要将引线固定在太小的值。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。