TimJohnston wrote:
I would have assumed you could have re-used ListInfo objects, but it appears you have to create a new one for each paragraph/bullet - is that right?
MigraDoc manages the list - you mark the paragraphs as list members.
You use
Code:
listinfo.ContinuePreviousList = false;
for the first entry in a list and
Code:
listinfo.ContinuePreviousList = true;//
for subsequent entries in the same list (makes a big difference for numbered lists).
Here are two helper routines I use:
Code:
bool continueList;
protected void DefineList()
{
continueList = false;
}
protected void AddToList(TemplateTable tt, string text)
{
ListInfo listinfo = new ListInfo();
listinfo.ContinuePreviousList = continueList;
listinfo.ListType = ListType.BulletList1;
Paragraph paragraph = Document.LastSection.AddParagraph(text);
paragraph.Style = tt.GetBulletListStyle(Document);
paragraph.Format.ListInfo = listinfo;
continueList = true;
}
TemplateTable provides formatting info and is not relevant here.
DefineList() only sets a member variable so next time a new list will be created.
AddToList() is called for each entry.