Search code examples
c#c#-4.0teleriktelerik-mvctelerik-reporting

How are bookmarks set in document with the telerik radflow editor in C#


So I have a project that I've taken over and can't seem to find any information relating to this specific issue. The project has an element that takes template documents and then proceeds to covert them to relevant information. Doing this it utilises radflow's document editor.

The imported file is a .docx file, when I break down the paragraphs it looks like the below

##PRODUCTS##\r\n##PTERMS##\r\n

in the actual code I then locate the bookmarks as follows

var bookmark = document.EnumerateChildrenOfType<BookmarkRangeStart>().FirstOrDefault(rangeStart => rangeStart.Bookmark.Name == "PRODUCTS");
                    if (bookmark != null) { }
bookmark = document.EnumerateChildrenOfType<BookmarkRangeStart>().FirstOrDefault(rangeStart => rangeStart.Bookmark.Name == "PTERMS");
                    if (bookmark != null) { }
var bookmarks = document.EnumerateChildrenOfType<BookmarkRangeStart>().Select(rangeStart => rangeStart.Bookmark.Name).ToList();

It will pick up PRODUCTS as a bookmark should I look at the bookmarks list, however it will not pick up PTERMS, I'm at a loss as to what is different between the 2 in terms of, if I should be looking for a list of approved bookmarks somewhere(if so where) or if there is some other backend element I need to set I can't just go and say editor.InsertBookmark("PTERMS") as these it would not fulfill the current needs

I've attempted things like editor.ReplaceText("##PTERMS##", "", true, false);, which doesn't exactly fulfill the current needs for the data I will be working with under the bookmark.

So all I'd really need is some possible assistance in better understanding how to set the bookmarks in the documents as I cannot seem to find any descriptive documentation relating to this issue


Solution

  • Ok having gone through significant additional troubleshooting, something they don't seem to mention is that it reads from the Word .docx bookmark formatting. So this has resolved the issue on my side, I feel a bit stupid for not bothering to check there, but also this is something that should be in their documentation.

    So tl;dr check your bookmark list in the docx file itself