In my Java project using Itext i’m creating a pdf file, In this i’m inserting a larger table inside the cell of another table.
I’m facing problem when the content of the table is larger than a page, the table is carried into next page. instead i want part of the data in previous page and only the data those exceeding the page need to go to next page.
How to achieve this, below is the code im using.
PdfPTable outerTable = new PdfPTable(2);
outerTable.setHeaderRows(1);
outerTable.setSpacingBefore(20);
outerTable.setWidthPercentage(100);
Phrase str_head = new Phrase("Sample Image \n", subFont);
Phrase act_head = new Phrase("Steps \n", subFont);
PdfPCell cell2;
cell2 = new PdfPCell(act_head);
outerTable.addCell(cell2);
cell2 = new PdfPCell(str_head);
cell2.setBorder(Rectangle.NO_BORDER);
outerTable.addCell(cell2);
/* content row*/
cell2 = new PdfPCell("-----Sample-------");
cell2.setBorder(Rectangle.NO_BORDER);
outerTable.addCell(cell2);
PdfPTable innerTable = new PdfPTable(2);
---------------
---------------
innerTable.add("XXX")//add more rows in so that page will overlow
---------------
---------------
cell2 = new PdfPCell(innerTable);
cell2.setBorder(Rectangle.NO_BORDER);
outerTable.addCell(cell2);
pretty simple if i know which itext version you are using. There are two properties
setSplitLate(false),setSplitRows(true). So you have to set these properties for both table. Please refer to the documentation to know more. code will look more like:I had used it long time ago in itext 2.1.4. So please check if these supported in your current version.(That why i asking for itext version being used)