Make ListItem Text Bold but not the List Icon itextsharp

限于喜欢 提交于 2019-12-12 05:08:35

问题


I am displaying a list using itextsharp in a pdf file .

Some of the Contents in a List item are being Bold as I asked it in my Question :

Bold some text in Pdf List

Now the problem is if I bold some text of Listitem , the List number is also getting Bold.

For Example :

1.Bold Text

it should be

  1. Bold Text

Here is the Snapshot :

How can I resolve this ?

Here is my Code :

 c1 = new Chunk("Earth Pit.", FontFactory.GetFont(FontFactory.TIMES_BOLD, 10,iTextSharp.text.Font.UNDERLINE));
        c2 = new Chunk(" The existing earth...", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10));
        p_chunk = new Paragraph();
        p_chunk.Add(c1);
        p_chunk.Add(c2);
        lst_terms.Add(new iTextSharp.text.ListItem(p_chunk));

回答1:


This works for me:

Chunk c1 = new Chunk("Earth Pit.", FontFactory.GetFont(FontFactory.TIMES_BOLD, 10,iTextSharp.text.Font.UNDERLINE));
Chunk c2 = new Chunk(" The existing earth...", FontFactory.GetFont(FontFactory.TIMES_ROMAN, 10));
ListItem li = new ListItem("", FontFactory.GetFont(TIMES_ROMAN, 10));
p.Add(c1);
p.Add(c2);
lst_terms.Add(li);

Why are you creating a Paragraph object when you actually need a ListItem?



来源:https://stackoverflow.com/questions/37831344/make-listitem-text-bold-but-not-the-list-icon-itextsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!