Hi,
I have an issue with displaying the page number in the PDF. My requirement
is to display page number like
"Page 1 of 20" and so on...
I have used the inner class explained in chapter05, but removed the code
that i dont want.
My inner class looks like this,

class HeaderFooter extends PdfPageEventHelper {
        
        /** Current page number (will be reset for every chapter). */
        int pageNum;
        PdfTemplate total;

        /**
         * Increase the page number.
         * @see com.itextpdf.text.pdf.PdfPageEventHelper#onStartPage(
         *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
         */
        public void onStartPage(PdfWriter writer, Document document) {
            pageNum++;
        }    
       
        /**
         * Adds the header and the footer.
         * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
         *      com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
         */
        public void onEndPage(PdfWriter writer, Document document) {
            Rectangle rect = writer.getBoxSize("art");
            ColumnText.showTextAligned(writer.getDirectContent(),
                    Element.ALIGN_LEFT, new Phrase(String.format("Page %d
of", writer.getPageNumber())),
                    (rect.getLeft() + rect.getRight()) / 2, rect.getBottom()
- 18, 0);  
            }
    }


my issue is i get this Page # of independent pages correct but not the total
page number.
The one that gets displayed on my pages is, "page 1 of ","page 2 of ".
I dont see the count of total pages. I beleive "write.getPageNumber()" gets
the total pages in the pdf.
Not sure where im wrong. can someone please help me with this?
Thanks in advance.

--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/page-numbers-in-footer-tp4219499p4219499.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to