powerpoint文件中的超链接不仅可以链接到外部url,还可以链接到文档中的特定幻灯片。本文将介绍如何使用spire.presentation创建一个链接到指定幻灯片的超链接。
c#
//创建powerpoint文档
presentation presentation = new presentation();
//添加幻灯片
presentation.slides.append();
//添加形状到第二张幻灯片
iautoshape shape = presentation.slides[1].shapes.appendshape(shapetype.rectangle, new rectanglef(20, 80, 200, 50));
//设置形状的填充颜色
shape.fill.filltype = fillformattype.solid;
shape.fill.solidcolor.color = color.gold;
//在形状上添加文本
shape.textframe.text = "跳转到第一页";
//创建clickhyperlink对象,链接到第一张幻灯片
clickhyperlink hyperlink = new clickhyperlink(presentation.slides[0]);
//在形状和文字上均设置跳转链接
shape.click = hyperlink;
shape.textframe.textrange.clickaction = hyperlink;
//保存文档
presentation.savetofile("output.pptx", fileformat.pptx2010);
vb.net
'创建powerpoint文档
dim presentation as new presentation()
'添加幻灯片
presentation.slides.append()
'添加形状到第二张幻灯片
dim shape as iautoshape = presentation.slides(1).shapes.appendshape(shapetype.rectangle, new rectanglef(20, 80, 200, 50))
'设置形状的填充颜色
shape.fill.filltype = fillformattype.solid
shape.fill.solidcolor.color = color.gold
'在形状上添加文本
shape.textframe.text = "跳转到第一页"
'创建clickhyperlink对象,链接到第一张幻灯片
dim hyperlink as new clickhyperlink(presentation.slides(0))
'在形状和文字上均设置跳转链接
shape.click = hyperlink
shape.textframe.textrange.clickaction = hyperlink
'保存文档
presentation.savetofile("output.pptx", fileformat.pptx2010)