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
[email protected]
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/