文本。如何调整 header 宽度(C#)?

iText. How to adjust header width (C#)?

我需要调整使用 iText 创建的 table 的 header 宽度。使用 table.SetWidths(lstMaxCount.ToArray()) 方法设置列宽,这是执行此操作的标准方法,但是有没有办法调整列 header 宽度以避免断线? 这是它现在的样子:

我认为一种解决方案是 header 显示在宽度较小的列的 2 行上。

我的建议是将 PackageNumber 列名称拆分为两个词,并在其中换行:

"Package" + Environment.NewLine + "Number"

使您的 header 高度足以容纳 2 行文本。

设置 PdfPCell 的 属性 NoWrap = false

还有其他选项可以将文本换行。您可以使用 ParagraphsChunks。你可以在这里看看:http://itextpdf.com/examples/iia.php?id=35enter link description here