Extract Links from the PDF File

The following code snippet also work with Aspose.PDF.Drawing library.

Links are represented as annotations in a PDF file, so to extract links, extract all the LinkAnnotation objects.

  1. Create a Document object.
  2. Get the Page you want to extract links from.
  3. Use the AnnotationSelector class to extract all the LinkAnnotation objects from the specified page.
  4. Pass the AnnotationSelector object to the Page object’s Accept method.
  5. Get all the selected link annotations into an IList object using the AnnotationSelector object’s Selected property.

The following code snippet shows you how to extract links from a PDF file.