We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page Link

How can I create a button with a link to a other page? I will create a text with a link too.

Thanks Sven

Dear Sven,

The following code adds an internal link on the shape object (rectangle) on the first slide that takes to third slide on click.

Is this code helpful for you?

void AddInternalHyperLink()


Presentation pres = new Presentation();

//Add three slides

Slide fstSlide = pres.GetSlideByPosition(1);

Slide sndSlide=pres.AddEmptySlide();

Slide thdSlide = pres.AddEmptySlide();

//Create a rectangle on first slide

Aspose.Slides.Rectangle rect=fstSlide.Shapes.AddRectangle(500, 500, 500, 500);

rect.FillFormat.Type = FillType.Solid;

rect.FillFormat.ForeColor = Color.Red;

//Add an internal link on rectangle that will take you to the third slide

//whenever rectangle is clicked



//And two elipses on other two slides

sndSlide.Shapes.AddEllipse(500, 500, 500, 500);

thdSlide.Shapes.AddEllipse(1000, 1000, 3000, 3000);

//Write the presentation to view



Dear Sven,

Please also see this code; this code illustrates how to create a text with a link to internal or external document.

Is this code helpful for you?

void AddSomeLink()


Presentation pres = new Presentation();

//Add two more slides with elipses

//---2nd Slide

Slide sndSlide = pres.AddEmptySlide();

sndSlide.Shapes.AddEllipse(500, 500, 1000, 1000);

//--3rd Slide

Slide thdSlide = pres.AddEmptySlide();

thdSlide.Shapes.AddEllipse(1000, 1000, 2000, 2000);

//Add a Textframe in first slide

Slide fstSlide = pres.GetSlideByPosition(1);

Aspose.Slides.Rectangle rect = fstSlide.Shapes.AddRectangle(600, 1000, 4700, 3000);

rect.LineFormat.ShowLines = false;

rect.AddTextFrame("Click Aspose or Third Slide");

//Add a text link to external hyperlink

TextFrame tf = rect.TextFrame;


Link lnk=tf.Links.AddLink();

lnk.Begin = tf.Text.IndexOf("Aspose");

lnk.End = lnk.Begin + "Aspose".Length;


//Add a text link to internal hyperlink

lnk = tf.Links.AddLink();

lnk.Begin = tf.Text.IndexOf("Third Slide");

lnk.End = lnk.Begin + "Third Slide".Length;


//Write presentation to view



Please see the same code as above in JAVA


public static void AddSomeLink() throws Exception


Presentation pres=new Presentation();

//Add two more slides with elipses

//--2nd Slide

Slide sndSlide=pres.addEmptySlide();

sndSlide.getShapes().addEllipse(500, 500, 1000,1000);

//--3rd Slide

Slide thdSlide=pres.addEmptySlide();

thdSlide.getShapes().addEllipse(500, 500, 1000,1000);

//Add a Textframe in first slide

Slide fstSlide=pres.getSlideByPosition(1);

com.aspose.slides.Rectangle rect=fstSlide.getShapes().addRectangle(600, 1000, 4700, 3000);


rect.addTextFrame("Click Aspose or Third Slide");

//Add a text link to external hyperlink

TextFrame tf=rect.getTextFrame();


Link lnk=tf.getLinks().addLink();


lnk.setEnd(lnk.getBegin()+ "Aspose".length());


//Add a text link to internal hyperlink


lnk.setBegin(tf.getText().indexOf("Third Slide"));

lnk.setEnd(lnk.getBegin()+ "Third Slide".length());


//Write presentation to view

pres.write(new FileOutputStream("c:\\outAddSomeLink.ppt"));