itextsharp.pdftable设置宽度,高度

关于itextsharp的单位换算,itextsharp使用磅作为单位,(1cm/2.54)*72=28.3464566928磅,需要的可以自行换算

1.设置总列宽

 PdfPTable table = new PdfPTable(16);

 table.TotalWidth = 500;//表格总宽度

 table.LockedWidth = true;//锁定宽度

2.设置pdftable类,设置单列表格宽度

PdfPTable table = new PdfPTable(3);
table.HorizontalAlignment = 0;
table.TotalWidth = 600;
table.LockedWidth = true;
float[] widths = new float[] { 80, 180, 280};//三列列宽不同若果是浮点数需要加f
table.SetWidths(widths);

3.高度自适应

cell.FixedHeight = height;

fixedHeight属性表示固定高度,单元格高度不会因内容超出范围而自动增加一行,而是会显示为省略号

4.设置高度

cell.MinimumHeight = 36;//设置行高

猜你喜欢

转载自blog.csdn.net/z282011862/article/details/82733591