Phrase phrase = new Phrase(String.valueOf(1942), getFont(yearNum)); (Phrase.setFont() is not retroactive)
Paulo ----- Original Message ----- From: "sujikin" <[email protected]> To: <[email protected]> Sent: Friday, April 10, 2009 2:48 PM Subject: [iText-questions] Unable to set font color in phrase of PdfPCell Hi, I am trying to set color in phrase of PdfPCell using below code..... PdfPCell cell = new PdfPCell(); Phrase phrase = new Phrase(String.valueOf(1942)); phrase.setFont(getFont(yearNum)); cell.setPhrase(phrase); table.addCell(cell); private Font getFont(int year) { Font font = null; if(year == 0){ font = FontFactory.getFont( FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL, new Color(0, 0, 255));//font.setColor(Color.BLUE); }else if(year == 1){ font = FontFactory.getFont( FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL, new Color(0, 255, 0));//font.setColor(Color.GREEN); }else if (year == 2){ font = FontFactory.getFont( FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL, new Color(255, 0, 255));//font.setColor(Color.MAGENTA); }else if (year == 3){ font = FontFactory.getFont( FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL, new Color(192, 192, 192));//font.setColor(Color.LIGHT_GRAY); }else{ font = FontFactory.getFont( FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL, new Color(64, 64, 64));//font.setColor(Color.DARK_GRAY); } return font; } The font is not showing the desired colors. In fact all are showing same colors. Earlier I had tried font.setColor(Color.RED); ...etc. Any help will be appreciated. Thanks & Regards Sujeet -- View this message in context: http://www.nabble.com/Unable-to-set-font-color-in-phrase-of-PdfPCell-tp22988280p22988280.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
