I assume you want the same date and time on all pages. So you should generate the date/time string only once and then use it on each page.
I assume you want different page numbers on each page. So you should generate the page number once for each page. It loooks like you are applying the page number twice. Once with the value when the document is opened (0, between "Page" and the date) and then again once for each page (the 1, 2, 3 appended at the end of each time stamp). You should consult the examples posted on the web. PHL ([email protected]) posted the ones he used, they are probably nice ones. /Klas dwhite skrev 2011-03-23 12:49: > Hi, I am just trying to add current page number to the footer of my document. > I followed the example from "iText in Action" and it works except for one > small issue. For some reason the page number gets broken up. I have pasted > the following code I use to write the footer but it produces the following > result for a 3 page document. > > > Confidential Page 0 03/23/11 07:36:221 > Confidential Page 0 03/23/11 07:36:222 > Confidential Page 0 03/23/11 07:36:223 > > The page numbers are being split after the 0 on either side of the dates. > Is there something I'm not doing correctly? > > Also, I tried using the example in the book > > class IHeaderFooter extends PdfPageEventHelper { > Phrase[] header = new Phrase[2]; > int pagenumber; > > with the same result. > > > ========== my code ====================== > public void onOpenDocument(PdfWriter writer, Document document) { > PDFHeaderFooter PDFUtil = new PDFHeaderFooter(); > String HeaderImageFile = > GeneralUtils.getConfigPropValue("report_header"); > document.setHeader(PDFUtil.GetHeader(HeaderImageFile)); > DateFormat dateFormat = new SimpleDateFormat("MM/dd/yy"); > DateFormat timeFormat = new SimpleDateFormat("HH:mm:ss"); > Date date = new Date(); > String CurrentDate = dateFormat.format(date); > String CurrentTime = timeFormat.format(date); > > HeaderFooter footer = null; > String pgNum = Integer.toString(writer.getPageNumber()); > String footerPhrase = "Confidential Page " + pgNum + " " + > CurrentDate + > " " + CurrentTime; > Phrase fp = new Phrase(footerPhrase); > footer = new HeaderFooter(fp, true); > footer.setBorder(Rectangle.NO_BORDER); > footer.setAlignment(Element.ALIGN_CENTER); > document.setFooter(footer); > } > > > -- > View this message in context: > http://itext-general.2136553.n4.nabble.com/Question-about-page-number-footers-tp3399290p3399290.html > Sent from the iText - General mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Enable your software for Intel(R) Active Management Technology to meet the > growing manageability and security demands of your customers. Businesses > are taking advantage of Intel(R) vPro (TM) technology - will your software > be a part of the solution? Download the Intel(R) Manageability Checker > today! http://p.sf.net/sfu/intel-dev2devmar > _______________________________________________ > 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 ------------------------------------------------------------------------------ Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar _______________________________________________ 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
