TextStyle.HyperlinkAddress
内容
[
隐藏
]TextStyle.HyperlinkAddress property
获取或设置超链接地址。设置此属性即可创建超链接。
public string HyperlinkAddress { get; set; }
示例
展示如何将超链接绑定到文本。
// 文档目录的路径。
string dataDir = RunExamples.GetDataDir_Tasks();
// 创建 Document 类的对象
Document doc = new Document();
RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
Outline outline = new Outline()
{
MaxWidth = 200,
MaxHeight = 200,
VerticalOffset = 100,
HorizontalOffset = 100
};
TextStyle textStyleRed = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10,
};
TextStyle textStyleHyperlink = new TextStyle
{
HyperlinkAddress = "https://www.google.com"
};
RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
.Append("This is ", textStyleRed)
.Append("hyperlink", textStyleHyperlink)
.Append(". This text is not a hyperlink.", TextStyle.Default);
OutlineElement outlineElem = new OutlineElement();
outlineElem.AppendChildLast(text);
// 添加大纲元素
outline.AppendChildLast(outlineElem);
// 初始化 Title 类对象
Title title = new Title() { TitleText = titleText };
// 初始化 Page 类对象
Page page = new Note.Page() { Title = title };
// 添加 Outline 节点
page.AppendChildLast(outline);
// 添加 Page 节点
doc.AppendChildLast(page);
// 保存 OneNote 文档
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
另请参阅
- class TextStyle
- namespace Aspose.Note
- assembly Aspose.Note