/// <summary> /// Load PDF document bookmark /// </summary> private void LoadBookmarks() { if (this.pdfDocumentViewer1.IsDocumentLoaded) { PdfDocumentBookmarkContainer container = this.pdfDocumentViewer1.GetBookmarkContainer(); if (container == null) { MessageBox.Show("Current PDF document has not bookmarks"); return; } this.treeViewBookmark.Nodes.Clear(); PdfDocumentBookmark[] bookmarks = container.Childs; for (int i = 0; i < bookmarks.Length; i++) { PdfDocumentBookmark bookmark = bookmarks[i]; TreeNode node = new TreeNode(); string title = bookmark.Title; node.Text = title; node.ForeColor = bookmark.Color; FontStyle style = (FontStyle)bookmark.Style; Font font = this.treeViewBookmark.Font; node.NodeFont = new Font(font, style); node.Tag = bookmark; this.treeViewBookmark.Nodes.Add(node); this.LoadChidNode(node); } } }
private void pdfDocumentViewer1_PdfLoaded(object sender, EventArgs args) { if (this.pdfDocumentViewer1.IsDocumentLoaded) { PdfDocumentBookmarkContainer container = this.pdfDocumentViewer1.GetBookmarkContainer(); if (container == null) { MessageBox.Show("Current PDF document has not bookmarks"); return; } this.treeView1.Items.Clear(); PdfDocumentBookmark[] bookmarks = container.Childs; if (bookmarks.Length > 0) { for (int i = 0; i < bookmarks.Length; i++) { PdfDocumentBookmark bookmark = bookmarks[i]; TreeViewItem node = new TreeViewItem(); node.Header = bookmark.Title; Color fontColor = bookmark.Color; node.Foreground = new SolidColorBrush(fontColor); node.Tag = bookmark; this.LoadChidNode(node); this.treeView1.Items.Add(node); } } } }