如何使用novacode.docx更改超链接样式 [英] How to change hyperlink styles using novacode.docx
本文介绍了如何使用novacode.docx更改超链接样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用Docx DLL我创建了超链接
其中,我试图自定义样式。
using Docx DLL I've created hyperlinks
where, I tried to customize styles.
public Hyperlink AddHyperLink(string name, string uri)
{
//FontFamily family = new FontFamily("Comic Sans MS");
//string Name= string.Format(name,Color.DarkOrange, FontStyle.Regular,family);
Hyperlink hp = document.AddHyperlink(name, new Uri(uri)); ;
return hp ;
}
在Docx中,Addhyperlink方法仅包含两个参数1)字符串2)URI
在novacode.Docx中,paragrapth只有样式方法,字符串没有样式功能。
如何为超链接设置不同的样式?
提前致谢。
我的尝试:
我试过
In Docx Addhyperlink method accteps only two parameters 1) string 2) URI
In novacode.Docx paragrapth only has style method, string has no style features.
how can I have different styles for hyperlink ?
Thanks in advance.
What I have tried:
I tried
string.Format
但是当作为参数传递的字符串,它会自动更改为默认样式。
But when string passed as parameter, it automatically changes to default style.
推荐答案
试试这个
try this
using (DocX document = DocX.Create(path))
{
Hyperlink h = document.AddHyperlink (name, new Uri(uri));
Paragraph p = document.InsertParagraph();
p.AppendHyperlink(h).Font(new FontFamily("Comic Sans MS")).FontSize(15).Color(Color.Blue);
document.Save();
}
这篇关于如何使用novacode.docx更改超链接样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文