diff --git "a/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink.slnx" "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink.slnx" new file mode 100644 index 000000000..b7abb2968 --- /dev/null +++ "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink.slnx" @@ -0,0 +1,3 @@ + + + diff --git "a/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Data/Input.docx" "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Data/Input.docx" new file mode 100644 index 000000000..e6ccdbe47 Binary files /dev/null and "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Data/Input.docx" differ diff --git "a/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Output/.gitkeep" "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Output/.gitkeep" new file mode 100644 index 000000000..5f282702b --- /dev/null +++ "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Output/.gitkeep" @@ -0,0 +1 @@ + \ No newline at end of file diff --git "a/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Output/Result.docx" "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Output/Result.docx" new file mode 100644 index 000000000..4f6d09094 Binary files /dev/null and "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Output/Result.docx" differ diff --git "a/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Program.cs" "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Program.cs" new file mode 100644 index 000000000..cc155966b --- /dev/null +++ "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Program.cs" @@ -0,0 +1,52 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.Drawing; + + +namespace Remove_underline_from_hyperlink +{ + internal class Program + { + static void Main(string[] args) + { + using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Data/Input.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + { + //Load an existing Word document into DocIO instance + using (WordDocument document = new WordDocument(fileStream, FormatType.Automatic)) + { + // Find all hyperlink fields in the document + List entities = document.FindAllItemsByProperty(EntityType.Field,"FieldType", "FieldHyperlink") as List; + if (entities != null) + { + // Process each hyperlink field + foreach (IEntity hyperlinkField in entities) + { + IEntity currentEntity = hyperlinkField; + // Iterate through sibling items until reaching the field end + while (currentEntity.NextSibling != null) + { + currentEntity = currentEntity.NextSibling; + // Remove underline from text ranges + if (currentEntity is WTextRange textRange) + { + textRange.CharacterFormat.UnderlineStyle = UnderlineStyle.None; + } + // Stop at field end marker + else if (currentEntity is WFieldMark fieldMark && fieldMark.Type == FieldMarkType.FieldEnd) + break; + } + } + } + //Create file stream + using (FileStream outputStream = new FileStream(Path.GetFullPath(@"../../../Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite)) + { + //Save the Word document to file stream + document.Save(outputStream, FormatType.Docx); + } + } + } + } + } +} + + diff --git "a/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink.csproj" "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink.csproj" new file mode 100644 index 000000000..a98e35cd2 --- /dev/null +++ "b/Paragraphs/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/.NET/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink/Remove\342\200\221underline\342\200\221from\342\200\221hyperlink.csproj" @@ -0,0 +1,27 @@ + + + + Exe + net8.0 + Remove_underline_from_hyperlink + enable + enable + + + + + + + + + Always + + + Always + + + Always + + + +