在Pdf列表中加粗一些文本一切都很好,但现在我希望列表项中的一些文本应该是粗体。例如:这是ListItem粗体文本。我怎样才能做到这一点?这是我的代码:Listlst_note=newList(List.ORDERED);lst_note.IndentationLeft=10f;lst_note.Add(newiTextSharp.text.ListItem("Thissingle**word**shouldbeBold",FontFactory.GetFont(FontFactory.TIMES_ROMAN,10)));免责声明。添加(lst_note);编辑我试过这个:Fontbold=newFont(FontFactory.GetFont(FontFactory.TIMES_BOLD,10,Font.BOLD));lst_terms.Add(newiTextSharp.text.ListItem("SomeText"+newChunk("thisshouldbold",bold),FontFactory.GetFont(FontFactory.TIMES_ROMAN,10)));但它不起作用请参阅此问题的答案:Regularandboldinasinglestring?答案是关于Paragraph的,但它也适用于ListItem,因为ListItem是Paragraph的子类:Fontregular=newFont(FontFamily.HELVETICA,12);Fontbold=Fontfont=newFont(FontFamily.HELVETICA,12,Font.BOLD);ListItemli=newListItem("NAME:",bold);li.Add(newChunk("regular",regular));您可以根据需要添加任意数量的Chunk对象,使用任意数量的不同字体。可以使用Paragraph和Chunks来完成,如下图:以上是C#学习教程:将Pdf列表中的部分文字加粗,分享全部内容,如果对大家有用,还需要进一步了解C#学习教程,希望大家多多关注——Chunkc1=newChunk("本单",newFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN,10,Font.NORMAL,BaseColor.BLACK)));Chunkc2=newChunk("word",newFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN,10,Font.BOLD,BaseColor.BLACK)));Chunkc3=newChunk("应该是粗体",newFont(iTextSharp.text.Font.FontFamily.TIMES_ROMAN,10,Font.NORMAL,BaseColor.BLACK)));Paragraphp2=newParagraph();p2.Add(c1);p2.Add(c2);p2.Add(c3);Listlst_note=newList(List.ORDERED);lst_note.IndentationLeft=10f;lst_note.Add(newiTextSharp.text.ListItem(p2);disclaimer.Add(lst_note);删除。如需转载请注明出处:
