estoy usando el iTextSharp.dll con el siguiente código:iTextSharp: ¿es posible establecer un color de fuente diferente para la misma celda y fila?
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 });
¿Podemos establecer diferentes colores de fuente para el título y la descripción, pero sólo utilizando una sola célula (es decir, sin necesidad de crear una nueva tabla)?
Cualquier ayuda en esta materia sería muy apreciada.
solución anterior se ve bien, pero no funciona. En este caso, ambas fuentes salieron igual: var titleChunk = new Chunk ("UPRN:", _fntHeading9); var descriptionChunk = new Chunk (keyPropertyId.ToString(), _fntNormal9); var phrase = new Phrase (titleChunk); phrase.Add (descriptionChunk); table.AddCell (nuevo PdfPCell (frase)); –
El código definitivamente funciona, ¿quizás los objetos de fuentes apuntan a la misma fuente? O hay otro problema en juego. – TimS
Definitivamente no funcionó. Los objetos de fuente son diferentes. Uno es Negrita, el otro es Normal. Este código funcionó: public static Font _fntNormal9 = FontFactory.GetFont ("Arial", 9, Font.NORMAL); public static Fuente _fntHeading9 = FontFactory.GetFont ("Arial", 9, Font.BOLD); var phrase = new Phrase(); phrase.Add (nueva frase ("UPRN:", _fntHeading9)); phrase.Add (new Phrase (keyPropertyId.ToString(), _fntNormal9)); table.AddCell (nuevo PdfPCell (frase)); –