I am trying to display mutiple tables in a single PDF and display page X of Y at the end of each page. X, Y should reset for every new table(Basically every new table should start with a new page.) Each table can vary and span accross multiple pages.I am ChapterAutoNumber, PdfPTable & custome event handler. I don't have problem while tables end in the middle of page(1 page of multiple pages). The problem comes when the table size matches page size.
If a table size is approximately equal to page size. Then onStartPage of new page(second) is invoked before onChapterEnds and onEndPage are invoked. So it displays page 1 of 2, when it has only one page. For tables ending in the middle of page, if it has 3 pages, page numbers are displayed correctly as 1 of 3 , 2 of 3 , 3 of 3. But when table size ends at the end of page, if there is 1 page, it display 1 of 2. Code looks like below: public void onChapter(PdfWriter arg0, Document arg1, float arg2, Paragraph arg3) { try { m_BaseFont = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); m_Cb = arg0.getDirectContent(); m_Template = m_Cb.createTemplate(85,140); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } public void onChapterEnd(PdfWriter arg0, Document arg1, float arg2) { m_Template.beginText(); m_Template.setFontAndSize(m_BaseFont, 8); String text = "of " + (arg0.getPageNumber() ); m_Template.showTextAligned(PdfContentByte.ALIGN_LEFT, text, 65, 0, 0); m_Template.endText(); } public void onEndPage(PdfWriter writer, Document arg1) { final int page = writer.getPageNumber(); String text = "Page " + page; if(m_Cb!=null){ m_Cb.beginText(); m_Cb.setFontAndSize(m_BaseFont, 8); m_Cb.showTextAligned(PdfContentByte.ALIGN_RIGHT,text,410,20,0); m_Cb.endText(); m_Cb.addTemplate(m_Template, 352.3f, 20); } } Please help. -- View this message in context: http://www.nabble.com/Page-Number-problem-when-table-ends-at-the-complete-end-of-the-page-tp25283855p25283855.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ 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/