I am using Itext for PDf generation.
I am using Table and Cell class to generate dynamic table and writing
texts dynamically in the cells. Text formatting is also done dynamically.
I have written function as following.....
private Cell setTemplateStyle(StyleVO[] styles , String text)
{
String fontName = "";
float size =0;
String fontWeight = "";
int fontWght = 0;
String textColor = "";
Color color = null;
Font font = null;
Cell cell = null;
if(styles != null && styles.length > 0 )
{
for (int i=0;i< styles.length; i++)
{
if(styles[i].getStyleId() == IReportConstants.FONT_FAMILY)
{
fontName = styles[i].getStyleValue();
}
else if(styles[i].getStyleId() == IReportConstants.FONT_SIZE)
{
size = Float.valueOf(styles[i].getStyleValue()).floatValue();
}
else if(styles[i].getStyleId() == IReportConstants.FONT_WEIGHT)
{
fontWeight = styles[i].getStyleValue();
if(fontWeight.equalsIgnoreCase("BOLD"))
{
fontWght = Font.BOLD;
}
else if(fontWeight.equalsIgnoreCase("BOLDITALIC"))
{
fontWght = Font.BOLDITALIC;
}
else if(fontWeight.equalsIgnoreCase("ITALIC"))
{
fontWght = Font.ITALIC;
}
else if(fontWeight.equalsIgnoreCase("NORMAL"))
{
fontWght = Font.NORMAL;
}
else if(fontWeight.equalsIgnoreCase("UNDERLINE"))
{
fontWght = Font.UNDERLINE;
}
}
else if(styles[i].getStyleId() == IReportConstants.COLOR)
{
textColor = styles[i].getStyleValue();
if(textColor.equalsIgnoreCase("Red"))
{
color = Color.RED;
}
else if(textColor.equalsIgnoreCase("BLACK"))
{
color = Color.BLACK;
}
else if(textColor.equalsIgnoreCase("BLUE"))
{
color = Color.BLUE;
}
else if(textColor.equalsIgnoreCase("CYAN"))
{
color = Color.CYAN;
}
if(textColor.equalsIgnoreCase("DARK_GRAY"))
{
color = Color.DARK_GRAY;
}
else if(textColor.equalsIgnoreCase("GRAY"))
{
color = Color.GRAY;
}
else if(textColor.equalsIgnoreCase("GREEN"))
{
color = Color.GREEN;
}
else if(textColor.equalsIgnoreCase("MAGENTA"))
{
color = Color.MAGENTA;
}
else if(textColor.equalsIgnoreCase("ORANGE"))
{
color = Color.ORANGE;
}
else if(textColor.equalsIgnoreCase("PINK"))
{
color = Color.PINK;
}
else if(textColor.equalsIgnoreCase("WHITE"))
{
color = Color.WHITE;
}
else if(textColor.equalsIgnoreCase("YELLOW"))
{
color = Color.YELLOW;
}
}
}
font = FontFactory.getFont(fontName,size,fontWght,color);
cell = new Cell (new Chunk(text, font));
}
return cell;
}
--- But this is not giving me color on the PDF file and the text is also
not seen.It disappears if I include color in the fonts.
Please help me ASAP
Vidhya M Mashru
Tata Consultancy Services Limited
Mailto: [EMAIL PROTECTED]
Website: http://www.tcs.com
Notice: The information contained in this e-mail message and/or attachments to
it may contain confidential or privileged information. If you are not the
intended recipient, any dissemination, use, review, distribution, printing or
copying of the information contained in this e-mail message and/or attachments
to it are strictly prohibited. If you have received this communication in
error, please notify us by reply e-mail or telephone and immediately and
permanently delete the message and any attachments. Thank you
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions