Hi there,
I am trying to generate a list on the position of a named bookmark in an template.
The list is generated and looks fine, but is a positioned at the very end of the document.
The code looks very similar to my code for generating a table on the position of a bookmark, but for a list it does not work.
Does anyone kwows what is going wrong? Is a section always generated at the very end of the document?
Thank for your help!
My code:
var bookmark = bookmarks.FirstOrDefault(b => b.Bookmark.Name == "PaymentMilestones");
if (bookmark is not null){
editor.MoveToInlineEnd(bookmark.Bookmark.BookmarkRangeStart);
var section = editor.InsertSection();
List list = document.Lists.Add(ListTemplateType.BulletDefault);
if (purchaseOrderPaymentMilestones is not null && purchaseOrderPaymentMilestones.Any())
{
foreach (var purchaseOrderPaymentMilestone in purchaseOrderPaymentMilestones)
{
var paragraph = section.Blocks.AddParagraph();
paragraph.Inlines.AddRun($"{purchaseOrderPaymentMilestone.Percentage.ToString("N0")}% {purchaseOrderPaymentMilestone.PaymentMilestone.FullDescription}");
paragraph.ListId = list.Id;
paragraph.ListLevel = 0;
}
}
}