/// <summary> /// 获取标签 /// </summary> /// <param name="bookmarks"></param> /// <param name="item"></param> /// <returns></returns> public Bookmark GetBookmark(Bookmarks bookmarks, string item) { if (bookmarks.Exists(item)) { foreach (Bookmark bookmark in bookmarks) { if (bookmark.Name == item) { return(bookmark); } } } return(null); }
public override void Run() { // 1. Opening the PDF file... string filePath = PromptFileChoice("Please select a PDF file"); using (var file = new File(filePath)) { Document document = file.Document; // 2. Get the bookmarks collection! Bookmarks bookmarks = document.Bookmarks; if (!bookmarks.Exists()) { Console.WriteLine("\nNo bookmark available (Outline dictionary not found)."); } else { Console.WriteLine("\nIterating through the bookmarks collection (please wait)...\n"); // 3. Show the bookmarks! PrintBookmarks(bookmarks); } } }
/// <summary> /// Extension method to check if a bookmark for a work item exists /// </summary> public static bool Exists(this Bookmarks bookmarks, int workItemId) { Guard.ThrowOnArgumentNull(bookmarks, "bookmarks"); return(bookmarks.Exists("w2t" + workItemId)); }