Hi,
I have a template that is a Word 2003 format. I have converted the template to docx and inserted some bookmarks in order to have the possibility to use document processing to insert text in the template. The template is provided as is so I can not change that.
I have managed to insert text successfully at the position of the bookmark, but I can not make the list work.
Here is the code I have
private void insertListAt(string bookmarkName, IEnumerable<
string
> values)
{
if(values == null || !values.Any())
{
return;
}
var bookmark = document.EnumerateChildrenOfType<
BookmarkRangeStart
>().FirstOrDefault(rangeStart => rangeStart.Bookmark.Name == bookmarkName);
if (bookmark != null)
{
editor.MoveToParagraphStart(bookmark.Paragraph);
foreach(string value in values)
{
var line = editor.InsertLine(value);
line.Paragraph.ListId = list.Id;
line.Paragraph.ListLevel = 4;
}
}
}
but this code does not work.
The values are placed one after the other with no new line between them and the list is not applied to the items