Add Hyperlink to an Image in PowerPoint in C#

Hyperlinks can direct readers to a web page, a file, an E-mail address, or other place in the same PowerPoint file. A hyperlink can be added to a text, an image or a shape. In the previous article, we've illustrated how to add hyperlink to text, this article is going to demonstrate how to add hyperlink to an image in PowerPoint using Spire.Presentation.

Detail steps:

Step 1: Initialize an object of Presentation class and Load the PowerPoint file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("Input.pptx");

Step 2: Get the first slide.

ISlide slide = presentation.Slides[0];

Step 3: Add image to slide.

RectangleF rect = new RectangleF(50, 300, 100, 100);
IEmbedImage image = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, @"logo.png", rect);

Step 4: Add hyperlink to image.

ClickHyperlink hyperlink = new ClickHyperlink("https://www.e-iceblue.com");
image.Click = hyperlink;

Step 5: Save the file.

presentation.SaveToFile("ImageHyperLink.pptx", FileFormat.Pptx2010);

Screenshot:

Add Hyperlink to an Image in PowerPoint in C#

Full code:

using Spire.Presentation;
using System.Drawing;
namespace InitializeHyperlink
{

    class Program
    {

        static void Main(string[] args)
        {
            //Initialize an object of Presentation class
            Presentation presentation = new Presentation();
            //Load the PowerPoint file
            presentation.LoadFromFile("test.pptx");

            //Get the first slide
            ISlide slide = presentation.Slides[0];

            //Add image to slide
            RectangleF rect = new RectangleF(50, 300, 100, 100);
            IEmbedImage image = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, @"logo.png", rect);

            //Add hyperlink to image
            ClickHyperlink hyperlink = new ClickHyperlink("https://www.e-iceblue.com");
            image.Click = hyperlink;

            //Save the file
            presentation.SaveToFile("ImageHyperLink.pptx", FileFormat.Pptx2010);

        }
    }
}