Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created October 13, 2021 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/489db43078dc098ec014662a64d3e81d to your computer and use it in GitHub Desktop.
Save GroupDocsGists/489db43078dc098ec014662a64d3e81d to your computer and use it in GitHub Desktop.
Add Highlight and Links Annotations to Annotate PDF documents using C#
// Create Hyperlinks in PDF using link annotations in C#
using (Annotator annotator = new Annotator(@"path/sample.pdf"))
{
LinkAnnotation link = new LinkAnnotation
{
CreatedOn = DateTime.Now,
PageNumber = 0,
Points = new List<Point>
{
new Point(120, 300),
new Point(600, 300),
new Point(120, 270),
new Point(600, 270)
},
Url = @"https://products.groupdocs.com/annotation"
};
annotator.Add(link);
annotator.Save(@"path/annotation-link.pdf");
}
// Highlight PDF using highlight annotation in C#
using (Annotator annotator = new Annotator(@"path/sample.pdf"))
{
HighlightAnnotation highlight = new HighlightAnnotation
{
BackgroundColor = 0xFFF000,
CreatedOn = DateTime.Now,
Opacity = 0.5,
PageNumber = 0,
Points = new List<Point>
{
new Point(120, 270),
new Point(600, 270),
new Point(120, 300),
new Point(600, 300)
}
};
annotator.Add(highlight);
annotator.Save(@"path/annotation-highlight.pdf");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment