Represents a hyperlink.
Inheritance Hierarchy Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.12.16
Syntax public sealed class Hyperlink : Inline,
IContentElement
Public NotInheritable Class Hyperlink
Inherits Inline
Implements IContentElement
The Hyperlink type exposes the following members.
Constructors Properties Methods | Name | Description |
---|
| Clone |
Clones this Hyperlink instance,
and optionally clones it's display elements.
|
TopExample See Developer Guide: How to add a hyperlink into a document
How to add a hyperlink into a document in C#
using SautinSoft.Document;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
AddHyperlink();
}
public static void AddHyperlink()
{
string docxPath = @"Hyperlink.docx";
DocumentCore dc = new DocumentCore();
Hyperlink hpl = new Hyperlink(dc, "http://www.zoo.org", "Welcome to Zoo!");
(hpl.DisplayInlines[0] as Run).CharacterFormat = new CharacterFormat() { Size = 16, FontColor = new Color("#358CCB"), UnderlineStyle = UnderlineType.Single };
hpl.ScreenTip = "Welcome to WoodLand Zoo!";
Paragraph p = new Paragraph(dc);
p.Inlines.Add(hpl);
p.ParagraphFormat.Alignment = HorizontalAlignment.Center;
dc.Content.Start.Insert(p.Content);
dc.Save(docxPath);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(docxPath) { UseShellExecute = true });
}
}
}
How to add a hyperlink into a document in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Module Sample
Sub Main()
AddHyperlink()
End Sub
Sub AddHyperlink()
Dim docxPath As String = "Hyperlink.docx"
Dim dc As New DocumentCore()
Dim hpl As New Hyperlink(dc, "http://www.zoo.org", "Welcome to Zoo!")
TryCast(hpl.DisplayInlines(0), Run).CharacterFormat = New CharacterFormat() With {
.Size = 16,
.FontColor = New Color("#358CCB"),
.UnderlineStyle = UnderlineType.Single
}
hpl.ScreenTip = "Welcome to WoodLand Zoo!"
Dim p As New Paragraph(dc)
p.Inlines.Add(hpl)
p.ParagraphFormat.Alignment = HorizontalAlignment.Center
dc.Content.Start.Insert(p.Content)
dc.Save(docxPath)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(docxPath) With {.UseShellExecute = True})
End Sub
End Module
See Also