import com.aspose.slides.Hyperlink; import com.aspose.slides.IPPImage; import com.aspose.slides.IPictureFrame; import com.aspose.slides.ISlide; import com.aspose.slides.License; import com.aspose.slides.Presentation; import com.aspose.slides.SaveFormat; import com.aspose.slides.ShapeType; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; public class InsertHyperlink { public static void main2(String[] args) throws Exception { // Main function to add a hyperlink to an image in PPTX // Load the product license to add a hyperlink License licHyperlink = new License(); licHyperlink.setLicense("Aspose.Total.lic"); // Generate an empty presentation using the Presentation class object to add hyperlink to an image Presentation presentationWithHyperlink = new Presentation(); // Access the first slide inside the slides collection of the presentation ISlide slideForPng = presentationWithHyperlink.getSlides().get_Item(0); // Add the PNG Image from the disk in the images collection of the presentation IPPImage imageFromDisk = presentationWithHyperlink.getImages().addImage(new FileInputStream(new File("aspose_logo.png"))); // Insert a picture frame in the shapes collection of the slide IPictureFrame pictureFrame = slideForPng.getShapes().addPictureFrame(ShapeType.Rectangle, 20, 20, 90, 90, imageFromDisk); // Insert the hyperlink for the added picture frame pictureFrame.setHyperlinkClick(new Hyperlink("https://www.aspose.com/")); // Add a tooltip for the hyperlink pictureFrame.getHyperlinkClick().setTooltip("More than 75% of Fortune 100 companies show trust in Aspose APIs"); // Save the presentation with hyperlinked image on the disk presentationWithHyperlink.save("preswithHyperlink.pptx", SaveFormat.Pptx); System.out.println("Done"); } }