iTextSharp-设置相同单元格同一行的不同字体颜色 [英] iTextSharp - set differnt font color same cell same row

查看:579
本文介绍了iTextSharp-设置相同单元格同一行的不同字体颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iTextSharp.dll

I am using iTextSharp.dll

var Title = "This is title";
var Description = "This is description";

Innertable.AddCell(new PdfPCell(new Phrase(string.Format("{0} {1}", Title, Description.Trim()), listTextFont)) { BackgroundColor = new BaseColor(233, 244, 249), BorderWidth = 0, PaddingTop = 4, PaddingLeft = -240, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_LEFT });



我们能否为标题和说明设置不同的字体颜色,但只能使用单个单元格而不创建新表.

提前致谢.



Can we set differnt font color for title and Description, but only using single cell without creating new table.

Thanks in advance. Any help in this matter would be greatly appreciated.

推荐答案

好吧..我终于设法自己解决了...

Okay.. i finally managed to solve it myself...

var Title ="This is title" 
    var (Description="This is description";
    var ListTitleCompFont = FontFactory.GetFont("trebuchet ms", 6);
    ListTitleCompFont.SetColor(8, 61, 134);
    ListRowContent = new PdfPCell();
    Title = Title.Trim();
    Title = Title + " ";
    Phrase ListTitlePhrase = new Phrase();
    ListTitlePhrase.Add(new Chunk(Title, ListTitleCompFont));
    ListTitlePhrase.Add(new Chunk(Description.Trim(), listTextFont));
    
    Innertable.AddCell(new PdfPCell(ListTitlePhrase) { BackgroundColor = new BaseColor(233, 244, 249), BorderWidth = 0, PaddingTop = 4, PaddingLeft = -240, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_LEFT });




耐心总是付出...




Patience always pays...


这篇关于iTextSharp-设置相同单元格同一行的不同字体颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆