I
I
iText Software2019-06-19 12:04:12
Java
iText Software, 2019-06-19 12:04:12

How to use an image as a list symbol?

I know what SetListSymbol(from the library ITextSharp) uses stringas a parameter, is it possible to use an image/icon instead? If so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iText_A, 2019-06-19
@iText_A

See the ListWithImageAsBullet example . In the example, we take an image of a light bulb and use it as a list marker:

Image image = Image.getInstance(IMG);
image.scaleAbsolute(12, 12);
image.setScaleToFitHeight(false);
List list = new List();
list.setListSymbol(new Chunk(Image.getInstance(image), 0, 0));
list.add("Hello World");
list.add("This is a list item with a lot of text. It will certainly take more than one line. This shows that the list item is indented and that the image is used as bullet.");
list.add("This is a test");
document.add(list);

The result looks like this:
Image as list marker

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question