views:

355

answers:

1

Hey,

I'm creating a PDF document using iTextSharp. I see how to create a new table with a number of columns but I can't see anyway to dynamically add a new column. The problem I have is I'm not going to know the number of columns I need straight away, so need to keep adding them

Can somebody please enlighten me or am I going to have to re-create the table each time I need to add a column?

Thanks Mat

A: 

ITextSharp tables work in a different way to HTML tables (which I guess you're used to).

All you need to tell it is the number of columns you have and then keep adding cells.

Say you create a pdfptable with 5 columns. The 5th cell you add will be on the first row and the 6th cell will be in the 1st column on your 2nd row.

The only downside to this is if you need to add rows where not all the cells are populated but I usually get around this by just adding an empty cell or a cell with a space in it.

CResults
I think you've misunderstood my question, I'm wanting to add a new column i.e. I have a table with 3 columns and I want to add a 4th column, not move on to a new row
mjmcloug
Urh, yep, sorry, trying to solve problems too early in the day! FWIW I've spent quite a bit of time with IText and don't know of a way you can do this.
CResults