1

How come this works:

lA = new List(List.ORDERED, List.ALPHABETICAL); 
lA.setLowercase(List.LOWERCASE);
lA.setPostSymbol(") ");

but this doesn't:

lQL = new List(List.UNORDERED); 
lQL.setListSymbol("=");
lQL.setPostSymbol("  ");

?

In the first example in front of every item is "a) " or "b) " or "c) " etc... In the second example in front of every item is only "=".

Before any ideas, two things. Firstly, I can't do it this way: lQL.setListSymbol("= ");. I could explain it, but just go with it, it's simpler. Secondly, I tried setting second string to "k " (so it's not only spaces), but the output was still "="...

What's happening?

4

2 回答 2

2

因为您已明确表明您想要一个带有List.UNORDERED. 因此,您不会收到任何商品订单,因此不会使用帖子符号。

从以下文档setPostSymbol

设置必须在列表符号中的数字或字母之后添加的字符串。

并从源代码List

  137       /**
  138        * In case you are using numbered/lettered lists, this String is added after the number/letter.
  139        * @since   iText 2.1.1
  140        */
  141       protected String postSymbol = ". ";

这个数字或字母只会添加到有序列表中,即List.ORDERED. 如果您检查 的构造函数的第一个参数List,您会看到它接收一个布尔值来指示列表是否已编号。由于您正在传递它List.UNORDERED,其值为false,因此您不会获得编号列表,因此postSymbol不会被附加。

于 2012-09-09T21:05:37.553 回答
0

要设置或取消设置数字、字母或项目符号,请使用以下单个代码列表,使用 iText pdf 输出或简单地使用列表。

例如,对于打印账单时通常不需要项目符号、字符串或数字的列表。

List list = new List(false, false, 50);
list.setListSymbol(" ");

谢谢你的询问。。

于 2014-01-16T03:18:16.223 回答