Well, doing the page import was confusing me. Once I got rid of it, the following code worked just fine. Still a bit of a mystery to me, but...

public void applyPageCount(File inFile, File outTestFile) {
    try {
    PdfReader reader = new PdfReader(inFile.toURL());
    PdfStamper stamper =
        new PdfStamper(reader, new FileOutputStream(outTestFile));
    stamper.setMoreInfo(meta);
    int pageTotal = reader.getNumberOfPages();
     PdfContentByte under; PdfTemplate tp;  BaseFont bf = ...;
     String text; String pageText;
     for (int i = 0; i<pageTotal;) {
        ++i;
        under = stamper.getUnderContent(i);
        pageText = "Page " + i  + " of 10";
        tp = under.createTemplate(500,500);
        under.addTemplate(tp, .1f,0,0, .1f, 0, 0);
        under.beginText();
        under.setFontAndSize(bf,8);
        text = "Signup Doc ,Page " + i + " of " + pageTotal;
        under.showTextAligned(PdfContentByte.ALIGN_LEFT,text,300,40, 0);
        under.endText();
     }
     stamper.close();
     } catch ...


David


Paulo Soares wrote:
Your code is wrong. See the example stamped.java at itextpdf.sf.net.

Best Regards,
Paulo Soares


-----Original Message-----
From:   David H. Young [SMTP:[EMAIL PROTECTED]
Sent:   Sunday, October 19, 2003 23:28
To:     [EMAIL PROTECTED]
Subject:        [iText-questions] using PdfStamper to update footer area...

I'm just not getting how to make this work, so here goes...

I'm trying to use PdfStamper to overwrite the footer areas of a ten page document that was generated using PdfCopy and and PdfWriter... I'm then reading in the generated file (inFile) for processing by PdfStamper(). There's not a lot of doc around PdfStamper... it appears that I don't have to do a new Document()...

PdfReader reader = new PdfReader(inFile.toURL());
PdfStamper stamper = new PdfStamper(reader,
     new FileOutputStream(outTestFile));
int n = reader.getNumberOfPages();
PdfContentByte cb; PdfImportedPage page; PdfTemplate tp;

for (int i = 0; i<n;) {
        ++i;
        cb = stamper.getUnderContent(i);
        page = stamper.getImportedPage(reader, i);

        tp = cb.addTemplate(page, 400, 400);
        tp.beginText();
        tp.setFontAndSize(bf,14);
        tp.setTextMatrix(100,100);
        tp.showText("Footer Test: page " + i);
        tp.endText();
}
stamper.close();

--
David H. Young
SAMBA Holdings, Inc.
Chief Technology Officer
1730 Monta�o NW
Albuquerque, NM 87107
505.797.2622 x113
http://www.samba.biz




-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise Linux in the Boardroom; in the Front Office; & in the Server Room http://www.enterpriselinuxforum.com
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions



------------------------------------------------------- This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100 http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions

.



--
David H. Young
SAMBA Holdings, Inc.
Chief Technology Officer
1730 Monta�o NW
Albuquerque, NM 87107
505.797.2622 x113
http://www.samba.biz




------------------------------------------------------- This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100 http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to