Create Toc to Bookmarks

I am creating toc to bookmark Level1 to level4 but I am Creating only created in only TWO levels any possible to create level1 to level4Levels.pdf (14.4 KB)

please help me,

@Nagasrinu

Would you please share your sample code snippet that you are using at your end? We will check and try to modify it in order to achieve your requirements.

public void TocToBookmarksCheck1(RegOpsQC rObj, Document pdfDocument)
        {
            try
            {
                if (pdfDocument.Pages.Count != 0)
                {
                    bool isTocPresent = false;
                    List<int> tocPages = new List<int>();
                    List<int> TotalPages = new List<int>();
                    List<String> values = new List<String>();
                    ArrayList t = new ArrayList();
                    ArrayList re = new ArrayList();
                    List<String> Destination = new List<String>();
                    List<link> li = new List<link>();
                    int linkcount = 0;
                    int linkToc = 0;
                    int linkLOF = 0;
                    int linkLoT = 0;
                    for (int i = 1; i <= pdfDocument.Pages.Count; i++)
                    {
                        string pattren = @"Table Of Contents|TABLE OF CONTENTS|Contents|CONTENTS|LIST OF TABLES|LIST OF FIGURES|LIST OF APPENDICES|LIST OF APPENDIXES";
                        Regex sample = new Regex(pattren, RegexOptions.IgnoreCase);
                        TextFragmentAbsorber textbsorber1 = new TextFragmentAbsorber(sample);
                        Aspose.Pdf.Text.TextSearchOptions textSearchOptions1 = new Aspose.Pdf.Text.TextSearchOptions(true);
                        textbsorber1.TextSearchOptions = textSearchOptions1;
                        pdfDocument.Pages[i].Accept(textbsorber1);
                        TextFragmentCollection txtFrgCollection = textbsorber1.TextFragments;
                        if (txtFrgCollection.Count > 0)
                        {
                            isTocPresent = true;
                            tocPages.Add(i);
                        }
                    }
                    if (tocPages.Count > 0)
                    {
                        int startpage = 0;
                        List<int> ExtraPage = new List<int>();
                        startpage = startpage = tocPages[0];
                        //Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);
                        //Regex match1 = new Regex(@"(?!=Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);

                        //Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);
                        Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);
                        //Regex match1 = new Regex(@"(?!=Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);                        Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);
                        Regex match1 = new Regex(@"(?!=Section|Table|Appendix|Figure|\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);

                        for (int x = startpage; x <= pdfDocument.Pages.Count; x++)
                        {
                            using (MemoryStream textStream = new MemoryStream())
                            {
                                TextDevice textDevice = new TextDevice();
                                Aspose.Pdf.Text.TextExtractionOptions textExtOptions = new
                                Aspose.Pdf.Text.TextExtractionOptions(Aspose.Pdf.Text.TextExtractionOptions.TextFormattingMode.MemorySaving);
                                textDevice.ExtractionOptions = textExtOptions;
                                textDevice.Process(pdfDocument.Pages[x], textStream);
                                // Close memory stream
                                textStream.Close();
                                // Get text from memory stream
                                string extractedText = Encoding.Unicode.GetString(textStream.ToArray());
                                string newText = extractedText;
                                string xyz = newText.Replace("\r\n", "$");
                                MatchCollection Matches = match.Matches(xyz);
                                MatchCollection Matches1 = match1.Matches(xyz);

                                if (Matches.Count > 0 || Matches1.Count > 0)
                                {
                                    TotalPages.Add(x);
                                    ExtraPage.Add(x);
                                }

                            }
                        }

                        TotalPages.Sort();

                        List<int> FinalPages = TotalPages.Distinct<int>().ToList();
                        foreach (int page in FinalPages)
                        {
                            if (isTocPresent)
                            {

                                AnnotationSelector selector = new AnnotationSelector(new Aspose.Pdf.Annotations.LinkAnnotation(pdfDocument.Pages[page], Aspose.Pdf.Rectangle.Trivial));
                                pdfDocument.Pages[page].Accept(selector);
                                IList<Annotation> list = selector.Selected;
                                try
                                {
                                    string title = "";

                                    foreach (LinkAnnotation a in list)
                                    {
                                        linkcount++;
                                        link model = new link();
                                        string content = "";
                                        TextFragmentAbsorber ta = new TextFragmentAbsorber();
                                        Rectangle rect = a.Rect;

                                        ta.TextSearchOptions = new Aspose.Pdf.Text.TextSearchOptions(a.Rect);
                                        ta.Visit(pdfDocument.Pages[page]);
                                        //get link text
                                        foreach (TextFragment tf in ta.TextFragments)
                                        {
                                            content = content + tf.Text;
                                        }
                                        Regex dd = new Regex(@"[.]{3,}((?=\s)\s\d+|\d+)");

                                        if (dd.IsMatch(content))
                                        {
                                            Match mm = dd.Match(content);
                                            title = content.Replace(mm.Value, "");
                                        }
                                        values.Add(title);
                                        t.Add(title);
                                        model.contents = title;
                                        model.destination = a.Action;
                                        re.Add(model);
                                        Regex Tocmatch = new Regex(@"(\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);
                                        Regex Tablematch = new Regex(@"(Table\s\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);
                                        Regex Figurematch = new Regex(@"(Figure\s\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);

                                        if (Tablematch.IsMatch(content))
                                        {
                                            linkLoT++;
                                        }
                                        else if (Figurematch.IsMatch(content))
                                        {
                                            linkLOF++;
                                        }
                                        else if (Tocmatch.IsMatch(content))
                                        {
                                            linkToc++;
                                        }
                                        else
                                        {
                                            linkToc++;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ErrorLogger.Error("JOB_ID:" + rObj.Job_ID + ", CHECK NAME: " + rObj.Check_Name + "\n" + ex);
                                    rObj.Job_Status = "Error";
                                    rObj.QC_Result = "Error";
                                    rObj.Comments = "Technical error: " + ex.Message;
                                }
                            }
                        }
                    }
                    int Toccount = 0;
                    int LoTcount = 0;
                    int LoFcount = 0;

                    ArrayList temp = t;
                    ArrayList temp1 = new ArrayList(re);

                    Regex Tocmatch1 = new Regex(@"Table Of Contents|TABLE OF CONTENTS|Contents|CONTENTS", RegexOptions.IgnoreCase);
                    Regex Tablematch1 = new Regex(@"LIST OF TABLES", RegexOptions.IgnoreCase);
                    Regex Figurematch1 = new Regex(@"LIST OF FIGURES", RegexOptions.IgnoreCase);

                    foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                    {
                        if (Tocmatch1.IsMatch(outlineItem.Title))
                        {
                            foreach (OutlineItemCollection Lotoutline in outlineItem)
                            {
                                if (outlineItem.Count > 0)
                                {
                                    foreach (link value in re)
                                    {
                                        if (Lotoutline.Title == value.contents.Trim())
                                        {
                                            temp1.Remove(value);
                                            Toccount++;
                                        }
                                    }
                                }

                            }
                        }
                        else if (Tablematch1.IsMatch(outlineItem.Title))
                        {
                            foreach (OutlineItemCollection Lotoutline in outlineItem)
                            {
                                if (outlineItem.Count > 0)
                                {
                                    foreach (link value in re)
                                    {
                                        if (Lotoutline.Title == value.contents.Trim())
                                        {
                                            temp1.Remove(value);
                                            LoTcount++;
                                        }
                                    }
                                }

                            }
                        }
                        else if (Figurematch1.IsMatch(outlineItem.Title))
                        {
                            foreach (OutlineItemCollection Lotoutline in outlineItem)
                            {
                                if (outlineItem.Count > 0)
                                {
                                    foreach (link value in re)
                                    {
                                        if (Lotoutline.Title == value.contents.Trim())
                                        {
                                            temp1.Remove(value);
                                            LoFcount++;
                                        }
                                    }
                                }

                            }
                        }
                    }
                    PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
                    // Open PDF file
                    bookmarkEditor.BindPdf(pdfDocument);
                    // Extract bookmarks
                    Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
                    int count = 0;
                    if (bookmarks.Count > 0)
                    {
                        foreach (Bookmark bookmark in bookmarks)
                        {
                            if (values.Count > 0)
                            {
                                foreach (link value in li)
                                {
                                    if (bookmark.Title == value.contents.Trim())
                                    {
                                        count++;
                                    }
                                }
                            }

                        }
                    }
                    int total = Toccount + LoFcount + LoTcount;
                    ArrayList temp2 = new ArrayList(temp1);
                    if (Toccount != linkToc)
                    {
                        rObj.QC_Result = "Failed";
                        rObj.Comments = "Toc Fails";
                    }
                    if (LoTcount != linkLoT)
                    {
                        rObj.QC_Result = "Failed";
                        rObj.Comments = "LoT fails";
                    }
                    if (LoFcount != linkLOF)
                    {
                        rObj.QC_Result = "Failed";
                        rObj.Comments = "LoF fails";
                    }
                    if (isTocPresent == true && bookmarks.Count == 0)
                    {
                        rObj.QC_Result = "Failed";
                        rObj.Comments = "No Bookmarks & Toc Present";
                    }
                    else if (count == linkcount)
                    {
                        rObj.QC_Result = "Passed";
                    }
                    else if (isTocPresent == false && TotalPages.Count == 0)
                    {
                        rObj.QC_Result = "Failed";
                        rObj.Comments = "No Toc,LoT,LoF & LoA";
                    }
                }
                else
                {
                    rObj.QC_Result = "Failed";
                    rObj.Comments = "No pages in document";
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Error("JOB_ID:" + rObj.Job_ID + ", CHECK NAME: " + rObj.Check_Name + "\n" + ex);
                rObj.Job_Status = "Error";
                rObj.QC_Result = "Error";
                rObj.Comments = "Technical error: " + ex.Message;
            }
        }

        public void TocToBookmarksFix1(RegOpsQC rObj, Document pdfDocument)
        {

            try
            {
                if (pdfDocument.Pages.Count != 0)
                {
                    bool isTocPresent = false;
                    List<int> tocPages = new List<int>();
                    List<int> TotalPages = new List<int>();
                    List<String> values = new List<String>();
                    ArrayList t = new ArrayList();
                    ArrayList re = new ArrayList();
                    List<String> Destination = new List<String>();
                    List<link> li = new List<link>();
                    int linkcount = 0;
                    int linkToc = 0;
                    int linkLOF = 0;
                    int linkLoT = 0;
                    for (int i = 1; i <= pdfDocument.Pages.Count; i++)
                    {
                        string pattren = @"Table Of Contents|TABLE OF CONTENTS|Contents|CONTENTS|LIST OF TABLES|LIST OF FIGURES|LIST OF APPENDICES|LIST OF APPENDIXES";
                        Regex sample = new Regex(pattren, RegexOptions.IgnoreCase);
                        TextFragmentAbsorber textbsorber1 = new TextFragmentAbsorber(sample);
                        Aspose.Pdf.Text.TextSearchOptions textSearchOptions1 = new Aspose.Pdf.Text.TextSearchOptions(true);
                        textbsorber1.TextSearchOptions = textSearchOptions1;
                        pdfDocument.Pages[i].Accept(textbsorber1);
                        TextFragmentCollection txtFrgCollection = textbsorber1.TextFragments;
                        if (txtFrgCollection.Count > 0)
                        {
                            isTocPresent = true;
                            tocPages.Add(i);
                        }
                    }
                    if (tocPages.Count > 0)
                    {
                        int startpage = 0;
                        List<int> ExtraPage = new List<int>();
                        startpage = startpage = tocPages[0];
                        //Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);
                        //Regex match1 = new Regex(@"(?!=Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);

                        //Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);
                        Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);
                        //Regex match1 = new Regex(@"(?!=Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);                        Regex match = new Regex(@"(Section|Table|Appendix|Figure|\d).*?[.]{3,}\d+", RegexOptions.IgnoreCase);
                        Regex match1 = new Regex(@"(?!=Section|Table|Appendix|Figure|\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);

                        for (int x = startpage; x <= pdfDocument.Pages.Count; x++)
                        {
                            using (MemoryStream textStream = new MemoryStream())
                            {
                                TextDevice textDevice = new TextDevice();
                                Aspose.Pdf.Text.TextExtractionOptions textExtOptions = new
                                Aspose.Pdf.Text.TextExtractionOptions(Aspose.Pdf.Text.TextExtractionOptions.TextFormattingMode.MemorySaving);
                                textDevice.ExtractionOptions = textExtOptions;
                                textDevice.Process(pdfDocument.Pages[x], textStream);
                                // Close memory stream
                                textStream.Close();
                                // Get text from memory stream
                                string extractedText = Encoding.Unicode.GetString(textStream.ToArray());
                                string newText = extractedText;
                                string xyz = newText.Replace("\r\n", "$");
                                MatchCollection Matches = match.Matches(xyz);
                                MatchCollection Matches1 = match1.Matches(xyz);

                                if (Matches.Count > 0 || Matches1.Count > 0)
                                {
                                    TotalPages.Add(x);
                                    ExtraPage.Add(x);
                                }

                            }
                        }

                        TotalPages.Sort();

                        List<int> FinalPages = TotalPages.Distinct<int>().ToList();
                        foreach (int page in FinalPages)
                        {
                            if (isTocPresent)
                            {

                                AnnotationSelector selector = new AnnotationSelector(new Aspose.Pdf.Annotations.LinkAnnotation(pdfDocument.Pages[page], Aspose.Pdf.Rectangle.Trivial));
                                pdfDocument.Pages[page].Accept(selector);
                                IList<Annotation> list = selector.Selected;
                                try
                                {
                                    string title = "";

                                    foreach (LinkAnnotation a in list)
                                    {
                                        linkcount++;
                                        link model = new link();
                                        string content = "";
                                        TextFragmentAbsorber ta = new TextFragmentAbsorber();
                                        Rectangle rect = a.Rect;

                                        ta.TextSearchOptions = new Aspose.Pdf.Text.TextSearchOptions(a.Rect);
                                        ta.Visit(pdfDocument.Pages[page]);
                                        //get link text
                                        foreach (TextFragment tf in ta.TextFragments)
                                        {
                                            content = content + tf.Text;
                                        }
                                        Regex dd = new Regex(@"[.]{3,}((?=\s)\s\d+|\d+)");

                                        if (dd.IsMatch(content))
                                        {
                                            Match mm = dd.Match(content);
                                            title = content.Replace(mm.Value, "");
                                        }
                                        values.Add(title);
                                        t.Add(title);
                                        model.contents = title;
                                        model.destination = a.Action;
                                        re.Add(model);
                                        Regex Tocmatch = new Regex(@"(\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);
                                        Regex Tablematch = new Regex(@"(Table\s\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);
                                        Regex Figurematch = new Regex(@"(Figure\s\d).*?[.]{3,}((?=\s)\s\d+|\d+)", RegexOptions.IgnoreCase);

                                        if (Tablematch.IsMatch(content))
                                        {
                                            linkLoT++;
                                        }
                                        else if (Figurematch.IsMatch(content))
                                        {
                                            linkLOF++;
                                        }
                                        else if (Tocmatch.IsMatch(content))
                                        {
                                            linkToc++;
                                        }
                                        else
                                        {
                                            linkToc++;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    ErrorLogger.Error("JOB_ID:" + rObj.Job_ID + ", CHECK NAME: " + rObj.Check_Name + "\n" + ex);
                                    rObj.Job_Status = "Error";
                                    rObj.QC_Result = "Error";
                                    rObj.Comments = "Technical error: " + ex.Message;
                                }
                            }
                        }
                    }
                    int Toccount = 0;
                    int LoTcount = 0;
                    int LoFcount = 0;

                    ArrayList temp = t;
                    ArrayList temp1 = new ArrayList(re);

                    Regex Tocmatch1 = new Regex(@"Table Of Contents|TABLE OF CONTENTS|Contents|CONTENTS", RegexOptions.IgnoreCase);
                    Regex Tablematch1 = new Regex(@"LIST OF TABLES", RegexOptions.IgnoreCase);
                    Regex Figurematch1 = new Regex(@"LIST OF FIGURES", RegexOptions.IgnoreCase);

                    foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                    {
                        if (Tocmatch1.IsMatch(outlineItem.Title))
                        {
                            foreach (OutlineItemCollection Lotoutline in outlineItem)
                            {
                                if (outlineItem.Count > 0)
                                {
                                    foreach (link value in re)
                                    {
                                        if (Lotoutline.Title == value.contents.Trim())
                                        {
                                            temp1.Remove(value);
                                            Toccount++;
                                        }
                                    }
                                }

                            }
                        }
                        else if (Tablematch1.IsMatch(outlineItem.Title))
                        {
                            foreach (OutlineItemCollection Lotoutline in outlineItem)
                            {
                                if (outlineItem.Count > 0)
                                {
                                    foreach (link value in re)
                                    {
                                        if (Lotoutline.Title == value.contents.Trim())
                                        {
                                            temp1.Remove(value);
                                            LoTcount++;
                                        }
                                    }
                                }

                            }
                        }
                        else if (Figurematch1.IsMatch(outlineItem.Title))
                        {
                            foreach (OutlineItemCollection Lotoutline in outlineItem)
                            {
                                if (outlineItem.Count > 0)
                                {
                                    foreach (link value in re)
                                    {
                                        if (Lotoutline.Title == value.contents.Trim())
                                        {
                                            temp1.Remove(value);
                                            LoFcount++;
                                        }
                                    }
                                }

                            }
                        }
                    }
                    PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
                    // Open PDF file
                    bookmarkEditor.BindPdf(pdfDocument);
                    // Extract bookmarks
                    Aspose.Pdf.Facades.Bookmarks bookmarks = bookmarkEditor.ExtractBookmarks();
                    int count = 0;
                    if (bookmarks.Count > 0)
                    {
                        foreach (Bookmark bookmark in bookmarks)
                        {
                            if (values.Count > 0)
                            {
                                foreach (link value in li)
                                {
                                    if (bookmark.Title == value.contents.Trim())
                                    {
                                        count++;
                                    }
                                }
                            }

                        }
                    }
                    int total = Toccount + LoFcount + LoTcount;
                    ArrayList temp2 = new ArrayList(temp1);
                    if (Toccount != linkToc)
                    {
                        Regex Tocmatch2 = new Regex(@"^(\d).*?", RegexOptions.IgnoreCase);

                        foreach (link we in temp1)
                        {
                            if (Tocmatch2.IsMatch(we.contents))
                            {
                                bool present = false;
                                foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                                {
                                    if (Tocmatch1.IsMatch(outlineItem.Title))
                                    {
                                        OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                        pdfOutline.Title = we.contents;
                                        pdfOutline.Italic = true;
                                        pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                        pdfOutline.Bold = true;
                                        pdfOutline.Action = we.destination;
                                        outlineItem.Add(pdfOutline);
                                        temp2.Remove(we);
                                        present = true;
                                    }
                                }
                                if (present == false)
                                {
                                    OutlineItemCollection TocOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                    TocOutline.Title = "Table of Contents";
                                    TocOutline.Italic = true;
                                    TocOutline.Bold = true;
                                    pdfDocument.Outlines.Add(TocOutline);
                                    foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                                    {
                                        if (Tablematch1.IsMatch(outlineItem.Title))
                                        {
                                            OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                            pdfOutline.Title = we.contents;
                                            pdfOutline.Italic = true;
                                            pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                            pdfOutline.Bold = true;
                                            pdfOutline.Action = we.destination;
                                            outlineItem.Add(pdfOutline);
                                            temp2.Remove(we);
                                        }
                                    }
                                }

                            }
                        }
                        rObj.Is_Fixed = 1;
                        rObj.Comments = rObj.Comments + ". Fixed";
                        //Console.WriteLine("Toc fails");
                    }
                    if (LoTcount != linkLoT)
                    {
                        Regex Tablematch2 = new Regex(@"(Table\s\d).*?", RegexOptions.IgnoreCase);

                        foreach (link we in temp1)
                        {
                            if (Tablematch2.IsMatch(we.contents))
                            {
                                bool present = false;
                                foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                                {
                                    if (Tablematch1.IsMatch(outlineItem.Title))
                                    {
                                        OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                        pdfOutline.Title = we.contents;
                                        pdfOutline.Italic = true;
                                        pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                        pdfOutline.Bold = true;
                                        pdfOutline.Action = we.destination;
                                        outlineItem.Add(pdfOutline);
                                        temp2.Remove(we);
                                        present = true;
                                    }
                                }
                                if (present == false)
                                {
                                    OutlineItemCollection LotOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                    LotOutline.Title = "List of Tables";
                                    LotOutline.Italic = true;
                                    LotOutline.Bold = true;
                                    pdfDocument.Outlines.Add(LotOutline);
                                    foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                                    {
                                        if (Tablematch1.IsMatch(outlineItem.Title))
                                        {
                                            OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                            pdfOutline.Title = we.contents;
                                            pdfOutline.Italic = true;
                                            pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                            pdfOutline.Bold = true;
                                            pdfOutline.Action = we.destination;
                                            outlineItem.Add(pdfOutline);
                                            temp2.Remove(we);
                                        }
                                    }
                                }
                            }
                        }
                        rObj.Is_Fixed = 1;
                        rObj.Comments = rObj.Comments + ". Fixed";
                        //Console.WriteLine("LoT fails");
                    }
                    if (LoFcount != linkLOF)
                    {
                        Regex Figurematch2 = new Regex(@"(Figure\s\d).*?", RegexOptions.IgnoreCase);

                        foreach (link we in temp1)
                        {
                            if (Figurematch2.IsMatch(we.contents))
                            {
                                bool present = false;
                                foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                                {
                                    if (Figurematch1.IsMatch(outlineItem.Title))
                                    {
                                        OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                        pdfOutline.Title = we.contents;
                                        pdfOutline.Italic = true;
                                        pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                        pdfOutline.Bold = true;
                                        pdfOutline.Action = we.destination;
                                        outlineItem.Add(pdfOutline);
                                        temp2.Remove(we);
                                        present = true;
                                    }
                                }
                                if (present == false)
                                {
                                    OutlineItemCollection LofOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                    LofOutline.Title = "List of Figures";
                                    LofOutline.Italic = true;
                                    LofOutline.Bold = true;
                                    pdfDocument.Outlines.Add(LofOutline);
                                    foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                                    {
                                        if (Tablematch1.IsMatch(outlineItem.Title))
                                        {
                                            OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                            pdfOutline.Title = we.contents;
                                            pdfOutline.Italic = true;
                                            pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                            pdfOutline.Bold = true;
                                            pdfOutline.Action = we.destination;
                                            outlineItem.Add(pdfOutline);
                                            temp2.Remove(we);
                                        }
                                    }
                                }
                            }
                        }
                        rObj.Is_Fixed = 1;
                        rObj.Comments = rObj.Comments + ". Fixed";
                        //Console.WriteLine("LoF fails");
                    }
                    if (temp2.Count > 0)
                    {
                        foreach (link we in temp2)
                        {
                            foreach (OutlineItemCollection outlineItem in pdfDocument.Outlines)
                            {
                                if (Tocmatch1.IsMatch(outlineItem.Title))
                                {
                                    OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
                                    pdfOutline.Title = we.contents;
                                    pdfOutline.Italic = true;
                                    pdfOutline.Color = System.Drawing.Color.DarkGreen;
                                    pdfOutline.Bold = true;
                                    pdfOutline.Action = we.destination;
                                    outlineItem.Add(pdfOutline);
                                }
                            }
                        }

                    }
                    if (isTocPresent == true && bookmarks.Count == 0)
                    {
                        rObj.Is_Fixed = 1;
                        rObj.Comments = rObj.Comments + ". Fixed";
                        //Console.WriteLine("No Bookmarks & Toc Present");
                    }
                    else if (count == linkcount)
                    {
                        rObj.QC_Result = "Passed";
                        //Console.WriteLine("matched" + count);
                        //Console.WriteLine("linkCount" + linkcount);
                        //Console.WriteLine("bookmarkcount" + bookmarks.Count);
                        //Console.WriteLine("outline" + total);
                        //Console.WriteLine("Toc" + linkToc);
                        //Console.WriteLine("LoT" + linkLoT);
                        //Console.WriteLine("LoF" + linkLOF);
                        //Console.WriteLine("Passed");
                    }
                    else if (isTocPresent == false && TotalPages.Count==0)
                    {
                        rObj.QC_Result = "Failed";
                        rObj.Comments = "No Toc,LoT,LoF & LoA";

                        //Console.WriteLine("matched" + count);
                        //Console.WriteLine("linkCount" + linkcount);
                        //Console.WriteLine("bookmarkcount" + bookmarks.Count);
                        //Console.WriteLine("outline" + total);
                        //Console.WriteLine("Toc" + linkToc);
                        //Console.WriteLine("LoT" + linkLoT);
                        //Console.WriteLine("LoF" + linkLOF);
                        //Console.WriteLine("Failed");
                    }
                }
                else
                {
                    rObj.QC_Result = "Failed";
                    rObj.Comments = "No pages in document";
                    //Console.WriteLine("No pages in document");
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Error("JOB_ID:" + rObj.Job_ID + ", CHECK NAME: " + rObj.Check_Name + "\n" + ex);
                rObj.Job_Status = "Error";
                rObj.QC_Result = "Error";
                rObj.Comments = "Technical error: " + ex.Message;
            }
        }
integrate chasa ada pampaa
        public class link
        {
            public string contents { get; set; }
            public PdfAction destination { get; set; }
        }

@Nagasrinu

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-54763

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.