In iText, how to set rowspan table cells with right column?

I need to draw a table as follows.

---------------
|  A   |   C  |
|------|      |
|  B   |      |
---------------      

The following code does not work. It creates a single row table without drawing cell "C":

PdfPTable table = new PdfPTable(2);
table.addCell("A");
table.addCell("B");
PdfPCell cell = new PdfPCell(new Phrase("C"));
cell.setRowspan(2);
table.addCell(cell);

Drawing the opposite table (with the rowspanning cell on the left) works just fine.

I noticed a similar question here , but the context is different (I am not working on an international application), so I think I can rephrase the question again.

+3
source share
2 answers

Tables are always displayed from left to right, from top to bottom, so you need to add A, then C, and then finally B.

PdfPTable table = new PdfPTable(2);
table.addCell("A");
PdfPCell cell = new PdfPCell(new Phrase("C"));
cell.setRowspan(2);
table.addCell(cell);
table.addCell("B");

iText , . - , . A R1C1, B R1C2, , , , .

+4

:

PdfPTable inner = new PdfPTable(1);
inner.addCell("A");
inner.addCell("B");

PdfPTable outer = new PdfPTAble(2);
outer.addCell(inner);
outer.addCell("C");
+3

All Articles