Hi Seniors, I have created PDF with nested tables,it has two two rows and second row has two cols.For some reason page is breaking intwo multiple pages with blank page. Please help me .. Code : http://old.nabble.com/file/p27494355/Test.pdf Test.pdf /** * */ package com.ak.pdf;
import java.awt.Color; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.text.SimpleDateFormat; import com.lowagie.text.Document; import com.lowagie.text.Element; import com.lowagie.text.Font; import com.lowagie.text.FontFactory; import com.lowagie.text.Paragraph; import com.lowagie.text.Rectangle; import com.lowagie.text.pdf.PdfPCell; import com.lowagie.text.pdf.PdfPTable; import com.lowagie.text.pdf.PdfWriter; /** * @author me * */ public class TestPDF { /** * */ public void generatePDFTable(){ try { OutputStream file = new FileOutputStream(new File("D:\\anil\\Test.pdf")); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); Font fonts = FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL); Font boldFont = FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(85f); PdfPCell cell; cell = new PdfPCell(new Paragraph("ABC Company MS")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBorderColor(Color.GREEN); cell.setColspan(2); table.addCell(cell); PdfPTable nestedTable = new PdfPTable(1); PdfPTable nestedTable1 = new PdfPTable(1); cell = new PdfPCell(new Paragraph("\nREB OFFER\n", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", fonts)); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("Rebate Amount: $" + "bbbbbbbbbbbbbbbbbbb", fonts)); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); // cell.setBorder(0); // nestedTable.addCell(cell); String dots = "...................."; cell = new PdfPCell(new Paragraph("\nREBATE FORM\n", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nName: " + dots, fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nAddress:" + dots, fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nCity: " + dots, fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nState: " + dots, fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nZip: " + dots, fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nEmail: " + dots, fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nStart Date: " + "01/02/2010", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("End Date: " + "01/02/2010", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("Postmark Date: " + "01/02/2010", fonts)); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("Received By Date: " + "01/02/2010", fonts)); cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nRED REQUIREMENTS\n", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); //cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("ccccccccccccccccccccccccccccc" + "cccccccccccccccccccccccccccccccccccccccccccccc" + "cccccccccccccccccccccccccccccccccccccccccccccccccccccc" + "ccccccccccccccccccccccccccccccccccccccccccccccccc" + "cccccccccccccccccccccccccccccccccccccdf" + "gggggggggggggggggggggggggggggggjfdshfgggggggg" + "ggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggggggggggggggg" + "gggggggggggggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + "gggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggggggggjshfsdfkggdfgd" + "gdfgdnfgkmdnfgndsfg" + "dfgdfsgbjdgkldflgd" + "gdfgbjdflkjffffffffffffffffffffff" + "ggggggggggggggggggggggggg" + "gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "f_______________________________________________fff" + "__________________________________________________dsfsdfs" + "fdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "ffffffffffffffffffffffffffffffff fffffffffffffffffffffffffff" + " fdgd" + "" + "" + "" + "" + "" + "" + "" + "" + "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + "fffffffffffffffffffffffffffffffffffffffffffffffffffffffEND", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); //cell.setBorder(0); //cell.setBackgroundColor(new Color(0xFF, 0x00, 0x00)); //nestedTable.getDefaultCell().setRowspan(1); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nCHECK REBATE STATUS:", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); // nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nCHECK REBATE STATUS:" + "hdfhsfjsdffsfsdf" + "\n" + "efrewkfljsdlkfnsdf" + "\n" + "9013403019", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); cell = new PdfPCell(new Paragraph("\nMail All Required Materials:" + "hhhhhhhhhhhh" + "\n" + "ggggggggggggggg" + "\n" + "vcvvvvvvvvvvvvvvvvv" + "," + "rrrrrrrrrrrrrrrrr" + " " + "mmmmmmmmmmmmmmmmmmmmmmm", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); // cell.setBorder(0); nestedTable.addCell(cell); table.addCell(nestedTable); cell = new PdfPCell(new Paragraph("REB RULES:", boldFont)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); //cell.setBorder(0); cell.setBorder(Rectangle.TOP); nestedTable1.addCell(cell); cell = new PdfPCell(new Paragraph("efjjdnffffffffffff" + "fgdfgsfdg" + "gdfgdfsgggggggggggggggggggggggg" + "gdfgggggggggggggggggggggggggg" + "fdgggggggggggggggggg" + "fdgdfggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggggg" + "ggggggggggggggggggggggggggggg" + "gggggggggggggggggggggggggggggggffffffffffffffff" + "" + "\n\nRebate sponsored by " + "CARDONE" + "products", fonts)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setBorder(0); nestedTable1.addCell(cell); table.addCell(nestedTable1); document.add(table); System.out.println("Done"); document.close(); file.close(); }catch(Exception e){ e.printStackTrace(); } } /** * @param args */ public static void main(String[] args) { TestPDF obj = new TestPDF(); obj.generatePDFTable(); } } Output attached. -- View this message in context: http://old.nabble.com/Issue-with-PDF-tables-in-itext-%3A-please-tp27494355p27494355.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/