Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Wed Jan 19, 2011 2:41 am

When I insert hyperlinks in Word. The words with hyperlinks are underlined automatically. If I don't just want to make the words with hyperlinks be in different color from other words without underline. How should I do?

smilesunshine99
 
Posts: 8
Joined: Tue Dec 21, 2010 7:09 am

Wed Jan 19, 2011 7:29 am

Thank you for your inquiry!
Hyperlink is a field, and there are some nodes in it. According to your requirement, you may set the format of the hyperlink by operating the textRange node. The textRange node is the third node of the hyperlink, so you should use NextSiling method to obtain the textrange node and set it. Code:
Field hyperlink = paragraph.AppendHyperlink("www.e-iceblue.com", "www.e-iceblue.com", HyperlinkType.WebLink);
TextRange text = hyperlink.NextSibling.NextSibling as TextRange;
text.CharacterFormat.Bold = true;
text.CharacterFormat.UnderlineStyle = UnderlineStyle.None;
e-iceblue support
User avatar

iceblue support
 
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Return to Spire.Doc