An external file link points to a file other than PDF document. Aspose.Pdf allows developers to create hyperlinks to Non-PDF files too.
Please follow the steps below to create a hyperlink to a Non-PDF file:
Example:
[C#]
//Create text paragraph with the reference of a section
Text text1 = new Text(sec1);
//Add the text paragraph in the paragraphs collection of the section
sec1.Paragraphs.Add(text1);
//Add a text segment in the text paragraph
Segment segment1 = text1.Segments.Add("this is a external file link");
//Assign a new instance of hyperlink to hyperlink property of segment
segment1.Hyperlink = new Hyperlink();
//Set the link type of the text segment to File
segment1.Hyperlink.LinkType = HyperlinkType.File;
//Set the path of the external Non-Pdf file
segment1.Hyperlink.LinkFile = "c:/images/apple.jpg";
[VB.NET]
'Create text paragraph with the reference of a section
Dim text1 As Text = New Text(sec1)
'Add the text paragraph in the paragraphs collection of the section
sec1.Paragraphs.Add(text1)
'Add a text segment in the text paragraph
Dim segment1 As Segment = text1.Segments.Add("this is a external file link")
'Assign a new instance of hyperlink to hyperlink property of segment
segment1.Hyperlink = New Hyperlink()
'Set the link type of the text segment to File
segment1.Hyperlink.LinkType = HyperlinkType.File
'Set the path of the external Non-Pdf file
segment1.Hyperlink.LinkFile = "c:/images/apple.jpg"
[XML]
<Text>
<Segment LinkFile="c:/Images/Apple.jpg" LinkType="File">
this is a local file link
</Segment>
</Text>