I have a requirement to get the current text that is within a bookmark before I replace it. I have tried several different methods without success. The closest I came was this
- Code: Select all
...
navigator.MoveToBookmark(bookmarkName);
var body = navigator.GetBookmarkContent();
Paragraph p = body.BodyItems.FirstItem as Paragraph;
string bookmarkContext = p.Text;
...
But this gets me the whole paragraph text in which the bookmark resides. Meaning we have a paragraph that shows:
Patient Name: [Patient_Name_Bookmark]
And p.Text gets me: "Patient Name: Patient_Name_Bookmark"
Where I only want the text "Patient_Name_Bookmark"
I also experimented with using Bookmark.BookmarkStart and Bookmark.BookmarkEnd, but I'm not sure how to get the text between the two.
It seems like this should be simple, but I'm just not able to get what I need. Honestly, I would have expected something like Bookmark.Text much like Paragraph.Text.