Hi Leo,
Thank you for your interest in Syncfusion products.
1) Way to retrieve Hyperlinks?Please refer the below code to retrieve the hyperlinks in the document:
foreach (Entity ent in document.ChildEntities)
{
if (ent is WSection)
{
WSection section = ent as WSection;
foreach (WParagraph paragraph in section.Body.Paragraphs)
{
for (int i = 0; i < paragraph.Items.Count; i++)
{
if (paragraph.Items[i] is WField && (paragraph.Items[i] as WField).FieldType == FieldType.FieldHyperlink)
{
Hyperlink hlink = new Hyperlink(paragraph.Items[i] as WField);
}
}
}
}
}
2) Proper way to removing a hyperlinks?Yes, for removing the hyperlink have to remove those mentioned fields since Hyperlink consists of WField, then goes WFieldMark ( field separator ), then WTextRange ( one or several ) and then WFieldmark ( field end)
Please refer the below code snippet to remove the hyperlinks:
foreach (Entity ent in document.ChildEntities)
{
if (ent is WSection)
{
WSection section = ent as WSection;
foreach (WParagraph paragraph in section.Body.Paragraphs)
{
for (int i = 0; i < paragraph.Items.Count; i++)
{
if (paragraph.Items[i] is WField && (paragraph.Items[i] as WField).FieldType == FieldType.FieldHyperlink)
{
while (!(paragraph.Items[i] is WFieldMark &&
(paragraph.Items[i] as WFieldMark).Type == FieldMarkType.FieldEnd))
paragraph.Items.RemoveAt(i);
// Remove field end
paragraph.Items.RemoveAt(i);
break;
}
}
}
}
}
Here is the sample for your reference:
http://websamples.syncfusion.com/samples/Bookmark_77765.zipPlease let me know if this helps you.
Best Regards,
Bhuvana