本文将介绍如何使用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
效果图: