Category / Section
How to insert hyperlinked image in PDF?
1 min read
You can achieve the hyperlinked image in PDF using PdfUriAnnotation. You can add the annotation in PdfPage and draw the image in PdfPage at the same bounds of annotation using PdfGraphics.
Refer to the following code example to draw the image at specified url annotation bounds.
C#
// Create a new instance of PdfDocument class. PdfDocument document = new PdfDocument(); //Add the page PdfPage page = document.Pages.Add(); //Image path string imagePath = @"..\..\Data\logo.png"; //Draw Image page.Graphics.DrawImage(PdfImage.FromFile(imagePath), new RectangleF(100, 70, 390, 130)); //Create url annotation PdfUriAnnotation url2 = new PdfUriAnnotation(new RectangleF(100, 70, 390, 130)); //Add the link url2.Uri = "http://www.syncfusion.com"; //Border url2.Border = new PdfAnnotationBorder(0, 0, 0); //Add the color url2.Color = new PdfColor(Color.White); //Add the annotation page.Annotations.Add(url2);
Sample Link
https://www.syncfusion.com/downloads/support/directtrac/general/HyperLinkImage-1945722345.zip