使ListItem文本粗体但不是列表图标itextsharp

使ListItem文本粗体但不是列表图标itextsharp

本文介绍了使ListItem文本粗体但不是列表图标itextsharp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在pdf文件中使用itextsharp显示一个列表。



我在问题中询问时,List项目中的一些内容是粗体:





如何解决这个问题?



这是我的代码:

  c1 = new Chunk(Earth Pit。,FontFactory.GetFont(F) ontFactory.TIMES_BOLD,10,iTextSharp.text.Font.UNDERLINE)); 
c2 = new Chunk(现有地球......,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));


解决方案

这对我有用:

  Chunk c1 = new Chunk(Earth Pit。,FontFactory.GetFont(FontFactory.TIMES_BOLD,10,iTextSharp.text.Font.UNDERLINE)); 
Chunk c2 = new Chunk(现有地球......,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);

为什么要创建段落对象时你实际上需要 ListItem


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));
解决方案

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?

这篇关于使ListItem文本粗体但不是列表图标itextsharp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:29