Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the cell width in itextsharp pdf creation

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 message.

width can not be set.

What should I do?..

like image 524
Fernando Avatar asked Feb 09 '12 09:02

Fernando


People also ask

How do I change cell width on Pdfpcell?

Case 1: relative widthsPdfPTable table = new PdfPTable(new float[] { 1, 3 }); If the width of table is 288, the width of the first column will now be 72 and the width of the second column will be 216. PdfPTable table = new PdfPTable(new float[] { 25, 75 });

What is the use of ITextSharp DLL?

What is ITextSharp? iTextSharp is a free and open source assembly that helps to convert page output or HTML content in a PDF file. Now add that DLL in the application.


2 Answers

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

like image 141
JP Hellemons Avatar answered Oct 13 '22 00:10

JP Hellemons


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 };
like image 21
Neha Avatar answered Oct 13 '22 00:10

Neha