如何在 C# 中的 iTextSharp 中设置 PdfPTable 的高度

How to Set Height of PdfPTable in iTextSharp in c#

如何在 iTextSharp 中设置 PdfPTable 的高度

我下载了最新版本的 iTextSharp dll。

我生成了一个 PdfPTable 对象,我必须设置它的单元格高度。

我试过:

table = new PdfPTable(colCount);
table.HorizontalAlignment = 1;
table.WidthPercentage = 100;
table.TotalHeight = 20000f;

但没有成功,因为异常是:

Can not assign a value to the property or to the indexer 'iTextSharp.text.pdf.PdfPTable.TotalHeight' because it is read-only.

我该怎么做?

请帮助我,在此先感谢您-

您不能设置单元格高度。 TotalHeight 属性 是只读的。通常,table 的高度由您添加到 table 的内容决定。

如果你真的想固定一个table的高度,你需要设置每个PdfPCellFixedHeight 属性。但是:如果您设置了单元格的固定高度,并且添加了不适合该单元格的内容,那么所有不适合的内容都将被忽略。