Free Support Forum -

Setting Underline for a bookmark


Can you please help me on how to set underline(single or double) for text of the bookmark using aspose.words(java).

Thanks in advance

Please try the following code:

private void SetBookmarkFont(Bookmark bookmark)


if (bookmark == null) return;

Node node = bookmark.BookmarkStart;

while (node != null && node != bookmark.BookmarkEnd)


if (node is Run)


Run run = (Run)node;

run.Font.Underline = Underline.Single;


node = node.NextSibling;



The code in c#. Please notify me if you will have trouble converting it to java. Please also mind that it will only work for bookmarks beginning and ending inside one paragraph. Bookmarks that span several paragraphs will require a more complex approach.

Best regards,

Hi Mikolvan,

Thanks a lot for such a quick solution. I really appreciate your work.