Erwan Cosnuau Online

Random stuff interesting to share 
« Back to blog

Merging cells, rowspand, colspan in iTextSharp PDFPCell PDFPTable

If you're using cells it's easy:
http://itextsharp.sourceforge.net/tutorial/ch05.html
example 5 (Chap0505.pdf)
it looks like this:

cell.Rowspan = 2;
cell.BorderColor = new Color(255, 0, 0);
table.addCell(cell);
table.addCell("1.1");
table.addCell("2.1");
table.addCell("1.2");
table.addCell("2.2");
table.addCell("cell test1");
cell = new Cell("big cell");
cell.Rowspan = 2;
cell.Colspan = 2;
cell.BackgroundColor = new Color(0xC0, 0xC0, 0xC0);
table.addCell(cell);


if you're using PDFPTable and PDFPCells no such things as an easy RowSpan ColSpan of course

UPDATE: COLSPAN works for PDFPCells only ROWSPAN DOESN'T WORK Pfeeeew makes life easier

We need to use nested tables what an horrible solution:

http://threebit.net/mail-archive/itext-questions/msg05899.html

Eample in Java: http://www.nabble.com/file/3929/RowSpanExample.java
Resulting PDF: http://www.nabble.com/file/3928/TableInCell.pdf

Have fun

Comments (0)

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter