How can I set cell width and height in itextsharp pdf cell ceration using c#. I just use
cell.width = 200f;
But it should display the error
You don't set the width of a cell.
you should set the width of the columns. And you can do that by applying them on the table object:
float[] widths = new float[] { 1f, 2f };
table.SetWidths(widths);
The answer from Neha is to set the width of the table object
more reference material here: http://www.mikesdotnetting.com/Article/86/iTextSharp-Introducing-Tables
int count=Gridview1.Columns.Count
PdfPTable table = new PdfPTable(count);
float[] columnWidths = new float[count];
for (int v = 0; v < count; v++)
{
if (v == 0) {
columnWidths[v] = 10f;
}
else if (v == 2)
{
columnWidths[v] = 30f;
}
else if(v == 3)
{
columnWidths[v] = 15f;
}
else if(v == 4)
{
columnWidths[v] = 18f;
}
else if(v == 5|| v == 6|| v == 7)
{
columnWidths[v] = 22f;
}
else
{
columnWidths[v] = 20f;
}
}
table.SetWidths(columnWidths);
http://indaravind.blogspot.in/2009/02/itextsharp-table-column-width.html
VB:
Dim intTblWidth() As Integer = {12, 10, 26, 10}
C#:
int[] intTblWidth = { 12, 10, 26, 10 };
cell.width = 200f;
you have to put capital W on width correct is cell.Width = 200f;