New to Telerik Document Processing? Start a free 30-day trial
Removing Hyperlinks from Text with RadFlowDocument
Updated on Jun 9, 2026
Environment
| Version | Product | Author |
|---|---|---|
| 2023.3.1106 | RadWordsProcessing | Desislava Yordanova |
Description
This article shows how to remove hyperlinks from text in an HTML document using the RadFlowDocument from RadWordsProcessing.
| Before | After |
|---|---|
![]() | ![]() |
Solution
The hyperlinks are stored with the help of FieldCharacter in RadFlowDocument. More information about the internal structure of the hyperlink fields is available in the following article: Hyperlink Field.
To remove hyperlinks from text in an HTML document using RadFlowDocument, follow these steps:
- Load the HTML document into
RadFlowDocumentusing the HtmlFormatProvider. - Enumerate the FieldCharacters elements in the document and delete the content of the hyperlink fields. The
DeleteContentmethod removes the hyperlink field elements and leaves only the text run that stores the text itself. - Enumerate the
Runelements in the document with the custom Hyperlink style and change their style to Normal.
csharp
private static RadFlowDocument RemoveHyperLinksFromHtml(string filePath = "sample.html")
{
Telerik.Windows.Documents.Flow.Model.RadFlowDocument document;
using (Stream input = File.OpenRead(filePath))
{
HtmlFormatProvider provider = new HtmlFormatProvider();
document = provider.Import(input);
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
var hyperlinkElements = document.EnumerateChildrenOfType<FieldCharacter>().Where(x => x.FieldCharacterType == FieldCharacterType.Start).ToList();
foreach (FieldCharacter hyperlink in hyperlinkElements)
{
editor.DeleteContent(hyperlink.FieldInfo.End, hyperlink.FieldInfo.End);
editor.DeleteContent(hyperlink.FieldInfo.Start, hyperlink.FieldInfo.Separator);
}
var hyperlinkRuns = document.EnumerateChildrenOfType<Run>().Where(x => x.StyleId.Contains("Hyperlink")).ToList();
foreach (Run r in hyperlinkRuns)
{
r.StyleId = "Normal";
}
string rawHtmlContent = provider.Export(document);
}
return document;
}

