We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

I am tried to apply the font property for the hyperlinks in my document but it does not apply

I am tried to apply the font property for the hyperlinks in my document but it does not apply. Kindly help me.
Please find the below input and expected output word document.Hyperlink12.docx (19.6 KB)
Expected_output12.docx (17.4 KB)

Please find the below code I used.

doc.Styles[StyleIdentifier.Hyperlink].Font.Color = Color.Blue;
doc.Styles[StyleIdentifier.Hyperlink].Font.Underline = Underline.None;
doc.Styles[StyleIdentifier.Hyperlink].Font.Size = 11;
doc.Styles[StyleIdentifier.Hyperlink].Font.Italic = false;
doc.Styles[StyleIdentifier.Hyperlink].Font.Name = "Segoe UI";

@Manasahr To get the desired output you should also change TOC styles and clear explicit formatting applied to hyperlinks:

Document doc = new Document(@"C:\Temp\Hyperlink12.docx");

StyleIdentifier[] tocStyles = new StyleIdentifier[]
{
    StyleIdentifier.Toc1,
    StyleIdentifier.Toc2,
    StyleIdentifier.Toc3,
    StyleIdentifier.Toc4,
    StyleIdentifier.Toc5,
    StyleIdentifier.Toc6,
    StyleIdentifier.Toc7,
    StyleIdentifier.Toc8,
    StyleIdentifier.Toc9,
};

// Chnage TOC styles
foreach (StyleIdentifier toc in tocStyles)
{
    doc.Styles[toc].Font.Color = Color.Blue;
    doc.Styles[toc].Font.Underline = Underline.None;
    doc.Styles[toc].Font.Size = 11;
    doc.Styles[toc].Font.Italic = false;
    doc.Styles[toc].Font.Name = "Segoe UI";
}

// Chnage Hyperlink style.
doc.Styles[StyleIdentifier.Hyperlink].Font.Color = Color.Blue;
doc.Styles[StyleIdentifier.Hyperlink].Font.Underline = Underline.None;
doc.Styles[StyleIdentifier.Hyperlink].Font.Size = 11;
doc.Styles[StyleIdentifier.Hyperlink].Font.Italic = false;
doc.Styles[StyleIdentifier.Hyperlink].Font.Name = "Segoe UI";

// Clear explicit formatting applied to hyperlink Run nodes
doc.GetChildNodes(NodeType.Run, true).Cast<Run>().Where(r => r.Font.StyleIdentifier == StyleIdentifier.Hyperlink).ToList()
    .ForEach(r => { r.Font.ClearFormatting(); r.Font.StyleIdentifier = StyleIdentifier.Hyperlink; });

// Update fields in the document.
doc.UpdateFields();

doc.Save(@"C:\Temp\out.docx");