PdfTemplate doesn't support annotations like that. It's package private because there are things that /can/ work, but You Have To Know What You Are Doing.
I believe ColumnText will help. IIRC, it can draw directly to a PdfContentByte/template/thingy. Yep. That'll do the trick. http://api.itextpdf.com/com/itextpdf/text/pdf/ColumnText.html --Mark Storer Senior Software Engineer Cardiff.com import legalese.Disclaimer; Disclaimer<Cardiff> DisCard = null; > -----Original Message----- > From: Thomas Hauk [mailto:t...@shaggyfrog.com] > Sent: Wednesday, June 09, 2010 1:32 PM > To: Post all your questions about iText here > Subject: [iText-questions] Placing text in a PdfTemplate > > I am currently generating a PDF by adding a PdfTemplate object > multiple times to a document (in an 8-up fashion). > > I wanted to dynamically place text in my PdfTemplate, which I did so > with the following code (in the function that creates my PdfTemplate > object): > > > pdfTemplate.beginText(); > pdfTemplate.setFontAndSize(baseFont, fontSize); > pdfTemplate.moveText(x, y); > pdfTemplate.showText(text); > pdfTemplate.endText(); > > This worked fine. > > But now I want to be able to set the alignment of the text. This might > be a little tricky to do manually, so I looked at some examples and > discovered the TextField class, which allows me to set alignment and > all sorts of other nice things. So I tried doing the following: > > > TextField textField = new TextField(writer, new Rectangle(x, y, x > +boxWidth, y+boxHeight), Integer.toString(i)); > textField.setText(text); > pdfTemplate.addAnnotation(textField.getTextField()); > > Oops -- addAnnotation() is package private for PdfTemplate! > > Any ideas? I'd also like to be able to set font colour as well, if > possible. > > P.S. hoping to avoid being told I'm asking why the sky is blue this > time -- fingers are crossed! > > -- > Thomas Hauk > Shaggy Frog Software > www.shaggyfrog.com > > > ------------------------------------------------------------------------ -- > ---- > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > iText-questions mailing list > iText-questions@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/itext-questions > > Buy the iText book: http://www.itextpdf.com/book/ > 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/ > > > No virus found in this incoming message. > Checked by AVG - www.avg.com > Version: 9.0.829 / Virus Database: 271.1.1/2913 - Release Date: 06/08/10 > 23:35:00 ------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.itextpdf.com/book/ 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/