A new row in pdfptable
14,179
In the constructor of PdfPTable you specify the number of columns in a row.
PdfPTable table = new PdfPTable(4) // 4 Columns
PdfPCell cell;
cell = new PdfPCell( new Phrase("Cell with colspan of 4") ) ;
cell. setColspan(4) ; // an entire row
anotherCell = new PdfPCell( new Phrase("Cell with colspan of 4") );
anotherCell.setColspan(4); // a second row
As you can see, a new row is created when you reach the colspan in the current row.
Author by
yogsma
Programmer. Founder of https://rentersvoices.com Developer of Android Application YFormulator (formerly Formulator). I used to write posts for Java Code Geeks here. Now I write better java code. Also you can check my github repositories github. You can download my ebook Spring Boot and Microservices Certified Scrum Master
Updated on June 04, 2022Comments
-
yogsma almost 2 years
I am using iText library to print certain data in table format in a pdf file. I have 11 columns and can have multiple rows. After creating header for titles of each column, how do I create a new row in pdfptable so that I can print the real data on a separate row.
-
yogsma about 13 yearsI guess I got it working by using table.completeRow(); so it finishes the row and starts a new row.
-
deldev about 9 yearstks very much, In fact, a new row only is created when you reach the colspan. This is very important!