Esempio n. 1
0
        public static void DeleteExtraBookmarks(List <KnowledgeItem> quickreferences, Document document)
        {
            pdftron.PDF.Bookmark bookmark = document.GetFirstBookmark();

            bookmarks = new List <pdftron.PDF.Bookmark>();

            while (bookmark.IsValid())
            {
                AddBookmarkAndItsChildren(bookmark);
                bookmark = bookmark.GetNext();
                if (!bookmark.IsValid())
                {
                    break;
                }
            }

            foreach (pdftron.PDF.Bookmark b in bookmarks)
            {
                // b.Delete();
                if (quickreferences.Where
                    (
                        q => String.Equals(q.CoreStatement, b.GetTitle(), StringComparison.OrdinalIgnoreCase) &&
                        ((Annotation)q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).FirstOrDefault().Target).Quads.FirstOrDefault().PageIndex == b.GetAction().GetDest().GetPage().GetIndex()
                    )
                    .Count() == 1)
                {
                    b.SetTitle((quickreferences.Where
                                (
                                    q => String.Equals(q.CoreStatement, b.GetTitle(), StringComparison.OrdinalIgnoreCase) &&
                                    ((Annotation)q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).FirstOrDefault().Target).Quads.FirstOrDefault().PageIndex == b.GetAction().GetDest().GetPage().GetIndex()
                                )
                                .FirstOrDefault().CoreStatement));
                }
                else if (quickreferences.Where(q => q.CoreStatement == b.GetTitle() && ((Annotation)q.EntityLinks.Where(e => e.Indication == EntityLink.PdfKnowledgeItemIndication).FirstOrDefault().Target).Quads.FirstOrDefault().PageIndex == b.GetAction().GetDest().GetPage().GetIndex()).Count() == 0)
                {
                    b.Delete();
                }
            }
        }
Esempio n. 2
0
        public static void AddBookmarkAndItsChildren(pdftron.PDF.Bookmark bookmark)
        {
            if (!bookmark.IsValid())
            {
                return;
            }

            bookmarks.Add(bookmark);

            List <pdftron.PDF.Bookmark> children = new List <pdftron.PDF.Bookmark>();

            bookmark = bookmark.GetFirstChild();
            while (bookmark.IsValid())
            {
                children.Add(bookmark);
                bookmark = bookmark.GetNext();
            }

            foreach (pdftron.PDF.Bookmark child in children)
            {
                AddBookmarkAndItsChildren(child);
            }
        }