Hyperlinks are normally used to associate external data to any specified area of the document. We can transform any part of the documents to hyperlinks using the link annotations. As a programmer, you can add these link annotations to documents within your .NET applications. In this article, we are going to discuss that how to create hyperlinks in PDF files using C#.
The following topics are covered below:
.NET API to Create Hyperlinks in PDF
GroupDocs.Annotation provides the annotation solution for different kinds of applications. Its .NET API allows manipulation and automation of various annotations in documents within your .NET applications. We will use its GroupDocs.Annotation for .NET API to create hyperlink annotations in the PDF file using C#.
PM> Install-Package GroupDocs.Annotation
Create Hyperlinks in PDF using C#
The following are the steps to create hyperlinks anywhere in the PDF file using C#.
- Load the source PDF document using Annotator class.
- Create the Link Annotation object.
- Define the hyperlink properties like url, page number, points, etc.
- Add the defined hyperlink to the loaded PDF document using Add method.
- Save the annotated PDF using Save method.
The following code sample shows how to convert any part of the PDF file into a hyperlink using C#.
The following is the output of the above code.
Get a Free API License
You can get a free temporary license in order to use the API without the evaluation limitations.
To conclude, you have learned how the link annotations can be added to create hyperlinks in PDF files using C#. Likewise, using link annotations, you can convert any part of the document into hyperlinks. Many other annotation types can also be added in a similar way using the same API. Learn further about the API by visiting the documentation. For queries, contact us via the forum.