I want to add 2 different bookmarks with 2 different names to be used for different purposes around the same text in a word document. I am aware this is possible through word manually.
Is it possible to do this through code?
Below is a code snippet I tried but could’nt achieve the desired output. Is it possible to do this? Or is there a better way to achieve this somehow? A better refactored code? Am I doing something wrong?
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.startBookmark("Bookmark 1"); builder.startBookmark("Bookmark 2"); builder.writeln(StringEscapeUtils.unescapeHtml("test title")); builder.endBookmark("Bookmark 1"); builder.endBookmark("Bookmark 2");
Also, i have another doubt. Can i add bookmarks before and after the below line of code?