Changing iText list bullet to a black spot

2019-07-01 18:54发布

问题:

I want to create an unordered list using iText. However, I don't want the default bullet to be dash, but a black spot (look to the spot right to your reputation marking your medals - something like that, but black). I don't know if iText has this already implemented (I couldn't find it), or do I have to do it manually.

The problem is, if I have to do it manually, since there are no black spots on a keyboard, I'd have to insert an image as the ListSymbol, but the setListSymbol method only accepts Chunk or String as an argument...

What do I do?

回答1:

The answer is in your own question. You can use a Chunk as list symbol. If you want to use a custom image (e.g. one that visualizes a black spot), you can wrap such an image inside a Chunk. If you don't want to draw such an image yourself, you could look for a font that has one (Webdings? Wingdings?) and use a Chunk with a character from that font.



回答2:

This is an example, this char is the bullet of unorder list in HTML.

 List list = new List(List.UNORDERED);
 list.setListSymbol("•");

 list.add(new ListItem("list 1");
 list.add(new ListItem("list 2"));
 list.add(new ListItem("list 3"));


标签: java list itext