I am using the InsertHyperlink function of DocumentBuilder to insert a hyperlink into my Aspose.Word.Document. Everything works perfectly as far as inserting the link . However, I am trying to find a way to color the hyperlink in generated Word document to blue. I tried to use the Aspose.Words.Styles collection to apply the font color to the Hyperlink style, but it didn’t seem to work. In fact, I iterated through the styles and it did not even find the Hyperlink StyleIdentifier. Any ideas?
Before calling DocumentBuilder.InsertHyperlink, set the formatting you want:
builder.PushFont(); //If you want to pop it later
builder.Font.Color = Color.Blue;
builder.Font.Underline = Underline.Single
builder.Font.UnderlineColor = Color.Blue;
builder.InsertHyperlink(...);
builder.PopFont(); //Restore the font that was during last PushFont.
It does not matter that there is no Hyperlink style in the styles collection. It is a built in MS Word style and Aspose.Words will create it for your automatically. Same like MS Word creates you Hyperlink style when you first use it.