Pdf generation from a jsp is asking for trouble. Redirect to a servlet; the
jsp was created to process text, not binary data. There are some examples
using page events. Run them first and only then go to the server. You must
walk before you run.
Best Regards,
Paulo Soares
----- Original Message -----
From: "Sean Leistico" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 29, 2002 1:36
Subject: Re: [iText-questions] Page numbering problem...new problems this
time (jsp's)
> Thanks, Paulo, for your quick reply, but now I'm discovering a new set
> of
> problems...
>
> The project I'm working on involves generating pdf's from inside a JSP.
> I
> figured out how a page event is supposed to work from the examples at
> the
> iText site, but I can't get them implemented and working from a JSP.
> Templates I can do without problem, but page events are being a pain,
> specifically...
>
> When I try to override onEndPage, and I include a "BaseFont bf =
> BaseFont.createFont..." statement inside the onEndPage override, I keep
> getting DocumentExceptions and IOExceptions (type #360) and it won't
> compile, OR it does compile and I get runtime problems ...
> ( java.lang.NullPointerException
> at com.lowagie.text.pdf.FontDetails.(Unknown Source)
> at com.lowagie.text.pdf.PdfWriter.addSimple(Unknown Source)
> at com.lowagie.text.pdf.PdfWriter.add(Unknown Source)
> at com.lowagie.text.pdf.PdfContentByte.setFontAndSize(Unknown Source)
> ....etc...
>
> and I can't for the life of me figure out how to make it work right. Is
> it
> a problem with JSP's, with iText, with my own Java coding? Is there
> another
> possible solution? Anyone else had this problem? All I want to do is
> dynamically number my pages...
>
> Thanks again in advance...
> sean
>
> ----- Original Message -----
> From: "Paulo Soares" <[EMAIL PROTECTED]>
> To: "Sean Leistico" <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Friday, June 28, 2002 12:31 PM
> Subject: Re: [iText-questions] Page numbering problem...I'm stumped...
>
>
> > From what I understand, you're adding the same template to all the
> pages.
> > It's no wonder that it prints always the same. You don't need a
> template.
> > Just create page event to write the header/footer to the content.
> >
> > Best Regards,
> > Paulo Soares
> >
> > ----- Original Message -----
> > From: "Sean Leistico" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, June 28, 2002 16:28
> > Subject: [iText-questions] Page numbering problem...I'm stumped...
> >
> >
> > > Hey all
> > >
> > > Got a bit of a problem, and I can't figure out what I'm doing wrong.
> > >
> > > I'm trying to do page numbers in a template that's posted to the
> bottom
> > > of
> > > each page of a pdf, but when I run it all the pages come out as page
> 1.
> > > No
> > > matter what I try (getPageNumber, integer iteration on each page,
> > > prayer,
> > > voodoo...) they all have the page number of 1 at the bottom. I've
> > > looked
> > > and looked and can't figure what I'm doing wrong. Any
> help/commentary
> > > would
> > > be greatly appreciated. I do hope that it's just me missing one or
> two
> > > simple things--this project's been a pain in the behind from the
> word go
> > > :-)
> > > Thanks in advance!
> > >
> > >
> > > source code snippets:
> > > (this is what -should- work, shouldn't it?)
> > >
> > > (sectionletter, revisiondate, catalogtitle are Strings)
> > > ...
> > > ...
> > > ...
> > > //creating a template for the bottom of the page, with automatic
> page
> > > numbering...
> > > PdfTemplate bottomtemplate = cb.createTemplate(612, 36);
> > > cb.setLineWidth(4);
> > > bottomtemplate.moveTo(54, 36);
> > > bottomtemplate.lineTo(558, 36);
> > > bottomtemplate.stroke();
> > > bottomtemplate.beginText();
> > > BaseFont bfb = BaseFont.createFont(BaseFont.HELVETICA,
> > > BaseFont.CP1252,
> > > BaseFont.NOT_EMBEDDED);
> > > bottomtemplate.setFontAndSize(bfb, 10);
> > > bottomtemplate.setTextMatrix(54, 18);
> > > bottomtemplate.showText(catalogtitle);
> > > bottomtemplate.setTextMatrix(558-(bfb.getWidthPoint(revisiondate,
> > > 10)),
> > > 18);
> > > bottomtemplate.showText(revisiondate);
> > > float a = bfb.getWidthPoint(catalogtitle, 10);
> > > float b = bfb.getWidthPoint(revisiondate, 10);
> > > bottomtemplate.setTextMatrix(((612 - a - b)/2) +
> > > bfb.getWidthPoint(catalogtitle, 10) ,18);
> > > bottomtemplate.showText(sectionletter + " - " +
> > > iwriter.getPageNumber());
> > > bottomtemplate.endText();
> > > ...
> > > ...
> > > ...
> > > //adding content and templates to the pages here...
> > > cb.addTemplate(bottomtemplate, 0, 0);
> > > sectioni.add(new Paragraph("xxx"));
> > >
> > > sectioni.newPage();
> > >
> > > cb.addTemplate(bottomtemplate, 0, 0);
> > > sectioni.add(new Paragraph("okay, this is frustrating"));
> > >
> > > sectioni.newPage();
> > >
> > > cb.addTemplate(bottomtemplate, 0, 0);
> > > sectioni.add(new Paragraph("why are all the pages numbered page
> 1?"));
> > > ...
> > > ...
> > > ...
> > > //...and, we're done...
> > > sectioni.close();
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This sf.net email is sponsored by:ThinkGeek
> > > Caffeinated soap. No kidding.
> > > http://thinkgeek.com/sf
> > > _______________________________________________
> > > iText-questions mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/itext-questions
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Caffeinated soap. No kidding.
> http://thinkgeek.com/sf
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
No, I will not fix your computer.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions