Last active
July 30, 2022 08:02
How to Add Hyperlink to an Image in Powerpoint using C#. For further details:https://kb.aspose.com/slides/python/how-to-add-hyperlink-to-an-image-in-powerpoint-using-python/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using Aspose.Slides; | |
using Aspose.Slides.Export; | |
namespace TestSlides | |
{ | |
public class InsertHyperlink | |
{ | |
public static void AddImageHyperlink() // Function to add hyperlink to an image in PPTX in C# | |
{ | |
// Load the product license | |
Aspose.Slides.License lic = new Aspose.Slides.License(); | |
lic.SetLicense("Aspose.Total.lic"); | |
// Using Presentation class object create an empty presentation | |
using (Presentation presentationWithHyperlink = new Presentation()) | |
{ | |
// Access the first slide inside the slides collection | |
ISlide slideForPng = presentationWithHyperlink.Slides[0]; | |
// Add the Image from the disk in the images collection of the presentation | |
IPPImage imageFromDisk = presentationWithHyperlink.Images.AddImage(File.ReadAllBytes("aspose_logo.png")); | |
// Insert a picture frame in the shapes collection of the slide | |
IPictureFrame pictureFrame = slideForPng.Shapes.AddPictureFrame(ShapeType.Rectangle, 20, 20, 90, 90, imageFromDisk); | |
// Insert the hyperlink for the added picture frame | |
pictureFrame.HyperlinkClick = new Hyperlink("https://www.aspose.com/"); | |
// Add a tooltip for the hyperlink | |
pictureFrame.HyperlinkClick.Tooltip = "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.Console.WriteLine("Done"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment