Extract a list or count of links/bookmarks/annotations from a document without iterating through each page

Is there an option to extract a list or count of links, bookmarks, or annotations from a document without iterating through each page? For a file with more than 20,000 links and bookmarks, this can cause memory issues, throw exceptions, or be very slow.

@prnksheela

Can you please share such document or any sample PDF file for our reference so that we can test the scenario in our environment and address it accordingly.

I am working with a document that is for restricted use, and I need to obtain permission before sharing it. Meanwhile, I would like to understand if there is any method or option available in Aspose.PDF to get a list or count of links, bookmarks, or annotations without iterating through each page.

Currently, I am using the following code to iterate through each page and extract the required information:

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(FileAbsolutePath);

PageCollection psd = pdfDocument.Pages;
AnnotationCollection annots = null;
int iTotalPages = psd.Count;

foreach (Page pageDic in psd)
{
    int page = pageDic.Number;
    string sourcePage = page.ToString();
    annots = pageDic.Annotations;
    for (int index = 1; index <= annots.Count; index++)
    {
        Annotation annot = annots[index];
        string Aname = annot.GetType().Name;

        if (Aname.Equals("LinkAnnotation"))
        {
            LinkProperties = ProcessPageLinkInfo(annot as LinkAnnotation, page, filepath, FileName, folder, pageDic, iTotalPages, DestinationFileNamedDestinations, pdfDocument, qcsettings);
        }
    }
    pageDic.Dispose();
    if (page % 500 == 0)
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
    }
}

We need to extract properties such as:

  • SourcePage
  • DestinationPage
  • Title
  • Action
  • RelativePath
  • NamedDestination
  • Openin
  • Magnification
  • LinkTextColor
  • Rectangle
  • Dimensions
  • Highlight
  • LineColor
  • LineStyle
  • LineThickness
  • TotalPageNumber
  • BookmarkLevelInNumber

Is there a more efficient way to achieve this without iterating through each page? Any guidance or suggestions would be greatly appreciated.

@prnksheela

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-58964

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.