I am new to ItextSharp Coding, where I have created a list
using the code
Dim li = New List(12)
li.ListSymbol = New Chunk(ChrW(&H2022), HeaderFont)
li.Add(New ListItem("Item 1", DefaultFont))
li.Add(New ListItem("Item 2", DefaultFont))
li.Add(New ListItem("Item 3", DefaultFont))
li.Add(New ListItem("Item 4", DefaultFont))
li.Add(New ListItem("Item 5", DefaultFont))
li.Add(New ListItem("Item 6", DefaultFont))
p1 = New Paragraph("", DefaultFont)
p1.IndentationLeft = 50
p1.SpacingBefore = 5
p1.Add(li)
myDocument.Add(p1)
DefaultFont and HeaderFont are delcared earlier for styling purpose. So just wanted to know is there a way I can add vertical Spacing between the listed items (Need to add extra space between listed items) using above piece of code..?
Please take a look at the ListWithLeading example.
In this example, I first create a list the way you did:
List list1 = new List(12);
list1.setListSymbol("\u2022");
list1.add(new ListItem("Value 1", font));
list1.add(new ListItem("Value 2", font));
list1.add(new ListItem("Value 3", font));
document.add(list1);
Note that I add the list directly to the document
, I don't see any reason why you would wrap it inside a Paragraph
.
I then create a list the way you want it to be created:
List list2 = new List(12);
list2.setListSymbol("\u2022");
list2.add(new ListItem(30, "Value 1", font));
list2.add(new ListItem(30, "Value 2", font));
list2.add(new ListItem(30, "Value 3", font));
list2.setIndentationLeft(60);
document.add(list2);
Note that I define the left indentation using the setIndentationLeft()
method (in C#, this is probably somethink like list2.IndentationLeft = 60;
) and I change the leading of the ListItem
objects from the default (which is 1.5 times the font size) to 30.
Note that the distance between the baselines of two consecutive lines is called the leading in PDF terminology. You can define this leading at the level of the ListItem
.