在Pdf列表中加粗一些文本 [英] Bold some text in Pdf List

查看:125
本文介绍了在Pdf列表中加粗一些文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am displaying some content in a List to show it in a pdf file.

每件事情都运行良好,但现在我想要一个列表项中的一些文本应该是大胆的。

Every thing is working fine , but Now I want some text in a List Item Should be Bold.

例如:

这是 ListItem Bold 文本。

我该怎么做?

这是我的代码:

 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)));

但这没效果

推荐答案

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

Please take a look at the answer of this question: How can I use regular and bold in a single String?

答案是关于段落,但它也适用于 ListItem ,因为 ListItem 是一个的子类

The answer talks about a Paragraph, but it also works for a ListItem as ListItem is a subclass of Paragraph:

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 对象你想要的许多不同的字体。

You can add as many Chunk objects using as many different fonts as you want.

这篇关于在Pdf列表中加粗一些文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆