A bookmark in Word works like a bookmark we might place in a book. We can use a bookmark to quickly jump to a specific location within a Word document. In this article, we’re going to introduce how to add bookmarks, replace the content of bookmarks and remove bookmarks in a Word document programmatically in Java using Free Spire.Doc for Java API.
Download Free Spire.Doc for Java from this link and import the Spire.Doc.jar file into your Java project.
Using the code
The following example demonstrates how to add simple bookmark and nested bookmark to a Word document.
Replacing the content of bookmarks
The following examples shows how to replace the content of an existing bookmark.
The following example shows how to remove a bookmark from a Word document but keep the content in the bookmark.
Hope you find this article helpful and informative.