Hello.

Apologies if this is the wrong place to ask these kinds of questions.

I've got a bunch of ready-made single-page PDF-files. (The templates) I 
connect a PdfReader to each one of them and concatenate them into a 
single PdfCopy. This results in a multi-page PDF where each page is an 
instance from the template-files.

3-page example using 2 different templates:
Page 1 (template 1)
Page 2 (template 2)
Page 3 (template 1)

..And so on. So far so good.

Furthermore, the resulting PDF needs to have some text added to it in 
different ways for every page. Currently I, as an iText newbie, are 
doing it like this:

PdfStamper stamper = new PdfStamper(reader, outputstream);
for (int i = 1; i <= 3; i++) {
     PdfContentByte cb = stamper.getOverContent(i);
     Graphics2D g2d = cb.createGraphics(w, h);
     g2d.drawString(text); //assume the text-variable here changes 
between every loop
     g2d.dispose()
}
stamper.close();

However, (and this is where things gets messed up) page 1 and 3 (who 
uses the same template) get the same text written to them twice, one 
piece of text put right on top of the other! It's as if I'm drawing on 
the same Graphics2D-object multiple times, or as if getOverContent() 
returns the same ContentByte for different pages.

What am I doing wrong here? How should I go about fixing this?

/Eric

------------------------------------------------------------------------------
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/

Reply via email to