在 Itextsharp c# 中更改列表项的字体大小

Change font size of List item in Itextsharp c#

我正在列表中打印 pdf 文件中的一些内容。

一切正常,但我想更改使用 List 显示的文本的字体大小。

我该怎么做?

这是我的代码:

List lst_rental = new List(List.UNORDERED);
list.IndentationLeft = 30f;
lst_rental.SetListSymbol("\u2022");
lst_rental.Add("Operators");
lst_rental.Add("Insurance");
lst_rental.Add("Lubricants, filters, etc.");
lst_rental.Add("Maintenance services.");
disclaimer.Add(lst_rental);

您并不是在自己的代码中创建 ListItem。您应该创建 ListItem 个对象。 ListItem class 是 Paragraph 的子 class,这意味着您可以在创建 ListItem 对象时定义字体。

请前往official iText website and use the search box to search for the word "ListItem". You'll find examples such as http://developers.itextpdf.com/question/how-can-i-generate-pdfua-compatible-pdf-itext

List list = new List();
list.Add(new ListItem("item with different font", font);
document.Add(list);

在 iText 5 中,您可以在 Font 对象中定义字体大小。在 iText 7 中,您可以在更高级别(文档级别、列表级别等)定义字体、字体大小和其他属性,但查看您的代码,我发现您使用的是 iTextSharp 5 或更早版本。