diff --git a/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text.sln b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text.sln new file mode 100644 index 000000000..37e70e340 --- /dev/null +++ b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Create-clickable-highlighted-text", "Create-clickable-highlighted-text\Create-clickable-highlighted-text.csproj", "{57C001A1-C538-4829-92C2-20D710656E0F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57C001A1-C538-4829-92C2-20D710656E0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57C001A1-C538-4829-92C2-20D710656E0F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57C001A1-C538-4829-92C2-20D710656E0F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57C001A1-C538-4829-92C2-20D710656E0F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A30E106F-36D5-42A4-A44F-0AE880C0565D} + EndGlobalSection +EndGlobal diff --git a/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Create-clickable-highlighted-text.csproj b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Create-clickable-highlighted-text.csproj new file mode 100644 index 000000000..fd83762f1 --- /dev/null +++ b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Create-clickable-highlighted-text.csproj @@ -0,0 +1,20 @@ + + + + Exe + net8.0 + Create_clickable_highlighted_text + enable + enable + + + + + + + + + Always + + + diff --git a/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Output/.gitkeep b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Output/.gitkeep new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Output/.gitkeep @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Program.cs b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Program.cs new file mode 100644 index 000000000..fc581d239 --- /dev/null +++ b/Paragraphs/Create_clickable_highlighted_text/.NET/Create-clickable-highlighted-text/Program.cs @@ -0,0 +1,52 @@ +using Syncfusion.DocIO; +using Syncfusion.DocIO.DLS; +using Syncfusion.Drawing; + +WordDocument document = new WordDocument(); +IWSection section = document.AddSection(); + +// Paragraph containing highlighted hyperlink word +IWParagraph para = section.AddParagraph(); + +para.AppendText("For detailed information, refer to "); + +IWField hyperlink = para.AppendHyperlink( + "Section5", // Bookmark name + "Section 5", // Display text + HyperlinkType.Bookmark); + + +WTextRange textRange = hyperlink.OwnerParagraph.ChildEntities[ + hyperlink.OwnerParagraph.ChildEntities.Count - 2] as WTextRange; + +if (textRange != null) +{ + textRange.CharacterFormat.HighlightColor = Color.Yellow; +} + +para.AppendText(" in this document."); + +//Add some content before destination +for (int i = 0; i < 5; i++) +{ + para = section.AddParagraph(); + para.AppendBookmarkStart($"Section{i}"); + para.AppendText($"Sample paragraph {i + 1}"); + para.AppendBookmarkEnd($"Section{i}"); +} + +// Bookmark destination +IWParagraph destinationPara = section.AddParagraph(); + +//Bookmark start +destinationPara.AppendBookmarkStart("Section5"); + +//Destination content +destinationPara.AppendText("Section 5 - Detailed Information"); + +//Bookmark end +destinationPara.AppendBookmarkEnd("Section5"); +section.AddParagraph().AppendText("End"); +//Save document +document.Save(@"../../../Output/Output.docx", FormatType.Docx); +document.Close(); \ No newline at end of file