On 14/09/2010 22:14, Jason Berk wrote:
> How do I get the color of a font used to create a phrase?
I can't think of any reason why you'd need to do that.
The code snippet you provide is... very awkward.
I don't see how that would ever work.
> // in the statement decorator
> Phrase footer = new Phrase(String.format(FOOTER, phone, email),
> Fonts.RED);
> statement.addPhrase(footer, 130, 275f);
>
> // in the statement class
> public void addPhrase(Phrase phrase, float x, float y) {
> String text = phrase.getContent();
> canvas.saveState();
> canvas.setColorStroke(Colors.BLACK);
> // fails - canvas.setColorStroke(phrase.getFont().getColor());
> // phrase.getFont().getColor() returns null
> canvas.beginText();
> canvas.moveText(x, y);
> canvas.setFontAndSize(phrase.getFont().getBaseFont(),
> phrase.getFont().getSize());
> canvas.showText(text);
> canvas.endText();
> canvas.restoreState();
> }
What do you do if the phrase has different fonts in
different color? This is a very complicated way to
achieve something that can be done using only one line:
ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, Phrase, x, y, 0);
See chapter 3 of the second edition of "iText in Action".
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
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/