Add Hyperlinks to Images in PowerPoint in Java

This article demonstrates how to add a hyperlink to an image in a PowerPint slide using Spire.Presentation for Java.

import com.spire.presentation.*;
import com.spire.presentation.drawing.FillFormatType;

import java.awt.geom.Rectangle2D;

public class AddHyperlinkToImage {

    public static void main(String[] args) throws Exception {

        //create a Presentation object
        Presentation presentation = new Presentation();

        //get the first slide
        ISlide slide = presentation.getSlides().get(0);

        //add an image to slide
        String imaPath = "C:\\Users\\Administrator\\Desktop\\logo.png";
        Rectangle2D.Float rect = new Rectangle2D.Float(50, 50, 220, 60);
        IEmbedImage image = slide.getShapes().appendEmbedImage(ShapeType.RECTANGLE, imaPath, rect);

        //set the line of image shape to none
        image.getLine().setFillType(FillFormatType.NONE);

        //add a hyperlink to image
        ClickHyperlink hyperlink = new ClickHyperlink("https://www.e-iceblue.com");
        image.setClick(hyperlink);

        //save the file
        presentation.saveToFile("output/ImageHyperLink.pptx", FileFormat.PPTX_2013);
    }
}

Add Hyperlinks to Images in PowerPoint in Java