How to Remove Hyperlink from PDF in C#

This tutorial directs how to remove hyperlink from PDF in C#. You will get all the details required to set the development environment, a set of steps to be followed while developing the application and a runnable sample code to remove link from PDF in C# such that none of the hyperlinks is left. This operation does not require any third-party tool or software to be installed on the system while running this application.

  1. Set the development environment to use Aspose.PDF for .NET to remove links
  2. Load the sample PDF file using the Document class object having multiple hyperlinks in it
  3. Parse through each page and access the collection of annotations on each page
  4. Parse through all the annotations and find the link type annotations
  5. Call the Delete() method from the Annotations collection class to remove the hyperlink
  6. Save the resultant PDF file having no hyperlinks in it

These steps provide consolidated information to remove hyperlink from PDF in C#. The process is commenced by loading the target PDF file and then parsing the annotations collection of each page to find the Link type annotation. Once the hyperlink annotation is found, it is deleted by calling the Delete() method of the AnnotationsCollection class.

The aforementioned code demonstrates the process of how to remove link from PDF in C# such that the hyperlink text remains there however only the link is removed. You can search different types of annotations like text, circle, polygon, polyline, line, square, free text, highlight, underline etc. If you want to delete entire annotations irrespective of the type, call the Delete() method without any arguments.

This quick tutorial has taught us how to develop a PDF hyperlink remover in C#. If you want to learn the process to add a hyperlink in a PDF, refer to the article on how to add hyperlink in PDF using C#.

 English