A web link points to a web location. Aspose.Pdf also allows developers to create hyperlinks to a web location.
Please follow the steps below to create a hyperlink to a web location:
Example:
[C#]
//Create text paragraph with the reference of a section
Text text2 = new Text(sec1);
//Add the text paragraph in the paragraphs collection of the section
sec1.Paragraphs.Add(text2);
//Add a text segment in the text paragraph
Segment segment2 = text2.Segments.Add("this is a web link");
//Assign a new instance of hyperlink to hyperlink property of segment
segment2.Hyperlink = new Hyperlink();
//Set the link type of the text segment to Web
segment2.Hyperlink.LinkType = HyperlinkType.Web;
//Set the URL of the web location to create a web link for the segment
segment2.Hyperlink.Url = "http://localhost/popup.htm";
[VB.NET]
'Create text paragraph with the reference of a section
Dim text2 As Text = New Text(sec1)
'Add the text paragraph in the paragraphs collection of the section
sec1.Paragraphs.Add(text2)
'Add a text segment in the text paragraph
Dim segment2 As Segment = text2.Segments.Add("this is a web link")
'Assign a new instance of hyperlink to hyperlink property of segment
segment2.Hyperlink = New Hyperlink()
'Set the link type of the text segment to Web
segment2.Hyperlink.LinkType = HyperlinkType.Web
'Set the URL of the web location to create a web link for the segment
segment2.Hyperlink.Url = "http://localhost/popup.htm"
[XML]
<Text>
<Segment Url="http://localhost/Images/SeaFood.jpg" LinkType="Web">
this is a web link
</Segment>
</Text>