在Pdf列表中加粗一些文本

我在列表中显示一些内容以在pdf文件中显示它。

每件事情都很好,但现在我想要列表项中的一些文字应该是大胆的。

例如 :

这是ListItem Bold Text。

我怎样才能做到这一点 ?

这是我的代码:

List lst_note = new List(List.ORDERED); lst_note.IndentationLeft = 10f; lst_note.Add(new iTextSharp.text.ListItem("This single **word** should be Bold", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))); disclaimer.Add(lst_note); 

编辑

我试过这个:

  Font bold = new Font(FontFactory.GetFont(FontFactory.TIMES_BOLD, 10, Font.BOLD)); lst_terms.Add(new iTextSharp.text.ListItem("Some Text "+ new Chunk("this should bold", bold), FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10))); 

但这没效果

请看一下这个问题的答案: 如何在单个字符串中使用常规和粗体?

答案是关于Paragraph ,但它也适用于ListItem因为ListItemParagraph的子类:

 Font regular = new Font(FontFamily.HELVETICA, 12); Font bold = Font font = new Font(FontFamily.HELVETICA, 12, Font.BOLD); ListItem li = new ListItem("NAME: ", bold); li.Add(new Chunk("regular", regular)); 

您可以根据需要使用尽可能多的不同字体添加任意数量的Chunk对象。

你可以使用ParagraphChunks来完成这个,如下所示:

 Chunk c1 = new Chunk("This single", new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK))); Chunk c2 = new Chunk("word", new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, BaseColor.BLACK))); Chunk c3 = new Chunk("should be Bold", new Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK))); Paragraph p2 = new Paragraph(); p2.Add(c1); p2.Add(c2); p2.Add(c3); List lst_note = new List(List.ORDERED); lst_note.IndentationLeft = 10f; lst_note.Add(new iTextSharp.text.ListItem(p2); disclaimer.Add(lst_note);