How can I create a button with a link to a other page? I will create a text with a link too.
Thanks Sven
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
rect.ClearLink();
rect.AddLink().SetInternalHyperlink(thdSlide);
//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
pres.Write("outAddInternalLink.ppt");
}
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;
tf.Links.Clear();
Link lnk = tf.Links.AddLink();
lnk.Begin = tf.Text.IndexOf("Aspose");
lnk.End = lnk.Begin + "Aspose".Length;
lnk.SetExternalHyperlink("http://www.aspose.com");
//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;
lnk.SetInternalHyperlink(thdSlide);
//Write presentation to view
pres.Write("outAddSomeLink.ppt");
}
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.getLineFormat().setShowLines(false);
rect.addTextFrame("Click Aspose or Third Slide");
//Add a text link to external hyperlink
TextFrame tf=rect.getTextFrame();
tf.getLinks().clear();
Link lnk=tf.getLinks().addLink();
lnk.setBegin(tf.getText().indexOf("Aspose"));
lnk.setEnd(lnk.getBegin()+ "Aspose".length());
lnk.setExternalHyperlink("http://www.aspose.com");
//Add a text link to internal hyperlink
lnk=tf.getLinks().addLink();
lnk.setBegin(tf.getText().indexOf("Third Slide"));
lnk.setEnd(lnk.getBegin()+ "Third Slide".length());
lnk.setInternalHyperlink(thdSlide);
//Write presentation to view
pres.write(new FileOutputStream("c:\\outAddSomeLink.ppt"));
}