Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using iTextSharp.dll

C#
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.
Posted

1 solution

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

C#
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...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900