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?

10 comments:

vishal said...

Thanks. Worked for me!!!

Timmy O'Tool said...

Thanks man, I was working exaclty for this.

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

DomFilk said...

you can try this free online pdf to word converter to convert pdf to word online.

AdeleB said...

PDF library for PDF rendering, like rendering PDF to text file

Unknown said...

Thank you so much

Vadivel Murthy said...

what about for dynamic columns( the columns counts will change depends on the user in my application ) in this case how can i set the column width statically, can you please suggest what to for dynamic columns.

nikkolayebba said...

There are certainly a whole lot of details like that to take into consideration. That could be a great level to bring up. I provide the thoughts above as common inspiration however clearly there are questions just like the one you deliver up the place a very powerful factor might be working in sincere good faith. I don?t know if best practices have emerged around things like that, but I'm positive that your job is clearly identified as a fair game. Each boys and girls feel the impact of just a moment’s pleasure, for the rest of their lives. casino play