You may use DocumentNavigator class as follows:
1) go to page referenced by bookmark and render
it
/// <summary>
/// Renders the page referenced by bookmark as an <see cref="ImageSource"/>
/// </summary>
/// <param
name="bookmark">The bookmark.</param>
/// <returns>Image source that represents current page, otherwise null.</returns>
public
ImageSource RenderPageReferencedByBookmark(Bookmark bookmark)
{
BitmapSource
bitmapSource = null;
if
( document.Navigator.GoToBookmark(bookmark) )
{
Page
page = document.Navigator.CurrentPage;
int
imageWidth = (int)page.Width;
int
imageHeight = (int)page.Height;
byte[]
image = page.RenderAsBytes(imageWidth, imageHeight, new
RenderingSettings());
bitmapSource = BitmapSource.Create( imageWidth, imageHeight, 72, 72, PixelFormats.Bgr32, null,
image, 4 * imageWidth );
}
return
bitmapSource;
}
2)
use its MoveForward, MoveBackward,
Move, GoToPage and respond to Navigated event
3)
retrieve its state by checking CurrentPage
or CurrentIndex properties
Another nice thing that you may get out of the sample is a TreeView
template that was used for bookmarks tree.
<TreeView Background="LightGray" Name="Bookmarks"
ItemsSource="{Binding Bookmark.Children}"
SelectedItemChanged="OnBookmarkSelectionChanged">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Title}"/>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
If you have any questions or suggestions regarding this or other code samples feel free to contact us or leave a comment here.