iTextSharp - Bug in the table functions?

Posted by Matthias on Stack Overflow See other posts from Stack Overflow or by Matthias
Published on 2010-02-23T21:04:01Z Indexed on 2010/04/06 20:23 UTC
Read the original article Hit count: 647

Filed under:
|

Hello all together,

I try to make a table like this:

PdfPTable Table = new PdfPTable(6);

PdfPCell Cell = new PdfPCell(new Phrase("a", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("b", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("c", Font1));
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("d", Font1));
Cell.Colspan = 2;
Table.AddCell(Cell);

That works fine. But changing the number of columns will destory the table. Is it a bug or do I make something wrong?

This code destroys the table:

PdfPTable Table = new PdfPTable(17);

PdfPCell Cell = new PdfPCell(new Phrase("a", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("b", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 10;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("c", Font1));
Cell.Colspan = 5;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("d", Font1));
Cell.Colspan = 5;
Table.AddCell(Cell);

Edit: The table should have this layout:

|-------------------------------------------------------|
| Cell "a" with | Cell "b" with | Cell "c", colspan = 5 |
| colspan = 2   | colspan = 10  |-----------------------|
| rowspan = 2   | rowspan = 2   | Cell "d", colspan = 5 |
|-------------------------------------------------------|

Best regards, Matthias

© Stack Overflow or respective owner

Related posts about itextsharp

Related posts about tables