Bookmarks
When you want to remember a certain page in your document, the easiest way to do this is to add a bookmark.
The current list of bookmarks can be retrieved with GetBookmarksAsync
:
1 | var bookmarks = await pdfView.Document.GetBookmarksAsync(); |
You can create a bookmark with a name and an Action
and add it to a page like this:
1 | var createdBookmark = await pdfView.Document.CreateBookmarkAsync(new Bookmark("Page 3", new GoTo(2))); |
In the above code, you created a bookmark with the name Page 3, which will be displayed in the bookmarks sidebar, and a GoTo
action so that the currently displayed page is changed to the provided page index when the bookmark is clicked on.
The returned Bookmark
object has a property Id
which is used to identify the bookmark when updating or removing it. For example, using the returned bookmark above, you can update it like this:
1 2 3 | createdBookmark.Name = "Page 2"; createdBookmark.Action = new GoTo(1); await pdfView.Document.UpdateBookmarkAsync(createdBookmark); |
Or you can remove it like this:
1 | await pdfView.Document.DeleteBookmarkAsync(createdBookmark.Id); |
You can also create a bookmark from Instant JSON:
1 2 3 4 5 6 7 8 | { "id": "this is ignored", "name": "My bookmark", "action": { "type": "goTo", "pageIndex": 2 } } |
1 2 | var bookmarkJson = LoadJsonObjectAsync("bookmark.json"); var createdBookmark = await pdfView.Document.CreateBookmarkAsync(Bookmark.FromJson(bookmarkJson)); |