如何在itextsharp pdf创建中设置单元格宽度

Fer*_*ndo 13 c# asp.net itextsharp

如何使用c#在itextsharp pdf cell ceration中设置单元格宽度和高度.我只是用

cell.width = 200f;
Run Code Online (Sandbox Code Playgroud)

但它应该显示错误消息.

宽度无法设定.

我该怎么办?..

JP *_*ons 36

您没有设置单元格的宽度.

你应该设置列的宽度.你可以通过在表对象上应用它们来做到这一点:

float[] widths = new float[] { 1f, 2f };
table.SetWidths(widths);
Run Code Online (Sandbox Code Playgroud)

Neha的答案是设置表格对象的宽度

更多参考资料:http://www.mikesdotnetting.com/Article/86/iTextSharp-Introducing-Tables


Neh*_*eha 12

http://indaravind.blogspot.in/2009/02/itextsharp-table-column-width.html

VB:

Dim intTblWidth() As Integer = {12, 10, 26, 10}
Run Code Online (Sandbox Code Playgroud)

C#:

int[] intTblWidth = { 12, 10, 26, 10 };
Run Code Online (Sandbox Code Playgroud)

  • 大声笑,这是VB,问题是C# (3认同)
  • 逻辑是一样的......他必须基本上定义单元格宽度 (3认同)