本文将介绍如何使用Spire.Presentation for .NET给PPT文档中的SmartArt图形的节点添加超链接。
C#
using Spire.Presentation;
using Spire.Presentation.Diagrams;
namespace SmartArt
{
class Program
{
static void Main(string[] args)
{
//创建Presentation实例
Presentation ppt = new Presentation();
//加载PPT文档
ppt.LoadFromFile("SmartArt.pptx");
//获取第一张幻灯片
ISlide slide = ppt.Slides[0];
//获取SmartArt图形
ISmartArt smartArt = slide.Shapes[0] as ISmartArt;
//添加指向网页的超链接到SmartArt图形的第一个节点
smartArt.Nodes[0].Click = new ClickHyperlink("https://www.e-iceblue.com");
//添加指向文档中指定幻灯片的超链接到SmartArt图形的第二个节点
smartArt.Nodes[1].Click = new ClickHyperlink(ppt.Slides[1]);
//保存结果文档
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2013);
}
}
}
VB.NET
Imports Spire.Presentation
Imports Spire.Presentation.Diagrams
Namespace SmartArt
Class Program
Private Shared Sub Main(ByVal args As String())
Dim ppt As Presentation = New Presentation()
ppt.LoadFromFile("SmartArt.pptx")
Dim slide As ISlide = ppt.Slides(0)
Dim smartArt As ISmartArt = TryCast(slide.Shapes(0), ISmartArt)
smartArt.Nodes(0).Click = New ClickHyperlink("https://www.e-iceblue.com")
smartArt.Nodes(1).Click = New ClickHyperlink(ppt.Slides(1))
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2013)
End Sub
End Class
End Namespace
效果图: