Add or Update Hyperlinks in PDF using C# .NET

PDF is a feature-rich document format that supports a range of elements including annotations, media, forms, etc. Hyperlink is an important element that is used to navigate within the PDF, from one PDF to another, to a web page, etc. While generating the PDF documents programmatically, you may often need to insert hyperlinks. Accordingly, in this article, you will learn how to add and update hyperlinks in PDF files in C# .NET.

To manipulate hyperlinks in PDF files, we will use Aspose.PDF for .NET. It is a popular API that allows you to create, process, and convert PDF files from within .NET applications. You can download the API’s binaries or install it using NuGet.

PM> Install-Package Aspose.PDF

The following are the steps to add a hyperlink to a PDF file in C#.

The following code sample shows how to add a hyperlink in PDF in C#.

You can also navigate to an external PDF file from one PDF using a hyperlink. The following steps demonstrate how to add a hyperlink to an external PDF file in C#.

The following code sample shows how to add hyperlink to an external PDF in C#.

In certain cases, you have to navigate from one page to another within a PDF document. The LocalHyperlink class is used to navigate to the particular page in a PDF. The following are the steps to achieve this.

The following code sample shows how to add hyperlink to navigate to a particular page in PDF.

You can also retrieve a hyperlink in a PDF file and update its properties. The following are the steps to perform this operation.

The following code sample shows how to update a hyperlink in PDF using C#.

Get a Free License

You can get a free temporary license in order to use Aspose.PDF for .NET without evaluation limitations.

Conclusion

In this article, you have learned how to add different types of hyperlinks in PDF files using C#. Furthermore, you have seen how to retrieve the hyperlinks from existing PDF files and update their properties programmatically. In addition, you can explore more about .NET PDF API using the documentation. In case you would have any questions or queries, you can contact us via our forum.

See Also