Wednesday, February 04, 2009

iTextSharp Table Column Width

iTextSharp is a nice PDF Library (Freeone) used for working with PDF Rendering in Web Application Programming. I used it for allowing my website to save content as PDF.

I found it very difficult at first for setting widths of individual columns of a table created from iTextSharp. But, its actually a pretty simple thing.

Code - 

Dim intTblWidth() As Integer = {12, 10, 26, 10}
myTable.SetWidths(intTblWidth)

In the first line, intTblWidth is an integer array denoting my four columns of the table. In the second line, we map the integer array to the table column width which is mapped automatically one by one. Pretty simple Huh?

6 comments:

vishal said...

Thanks. Worked for me!!!

Timmy O'Tool said...

Thanks man, I was working exaclty for this.

Supdt. of Posts said...

THANK YOU

antish said...

Too Good....... Thanks

Richardson said...

Works only for first line em PdfPTable for me, the others rows are "default" width.

nevizade said...

worked , thanks