How to use an image as list symbol?

I know that SetListSymbol (from the ITextSharp library) expects a string as a parameter, but is it possible to use an image/icon somehow? If so, how?

31st May 2016
admin-marketing

Posted on StackOverflow on Aug 20, 2015 by lucas.mdo

Please take a look at the ListWithImageAsBullet example. It takes the image of a light bulb and uses it as if it were a bullet:

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 look like this:

Image as a bullet

Image as a bullet

Click this link if you want to see how to answer this question in iText 5.


Share this article

Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now