Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes HyperLink AddStyle not being applied #93

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static void Example_BasicWordWithHyperLinks(string folderPath, bool ope
Console.WriteLine(document.Sections[0].ParagraphsHyperLinks.Count);
Console.WriteLine(document.ParagraphsHyperLinks.Count);
Console.WriteLine(document.Sections[0].HyperLinks.Count);
document.AddParagraph("Test HYPERLINK ").AddHyperLink(" to website?", new Uri("https://evotec.xyz"));
document.AddParagraph("Test HYPERLINK ").AddHyperLink(" to website?", new Uri("https://evotec.xyz"), true);

document.AddParagraph("Test Email Address ").AddHyperLink("Przemysław Klys", new Uri("mailto:[email protected]?subject=Test Subject"));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -14,6 +14,7 @@ public static void EasyExample(string folderPath, bool openWord) {

using (WordDocument document = WordDocument.Create(filePath)) {
var para = document.AddHyperLink("Test", new Uri("https://evotec.xyz"));
var para1 = document.AddHyperLink("Test", new Uri("https://evotec.xyz"), addStyle: true);

document.Save(openWord);
Console.WriteLine("IsValid: " + document.DocumentIsValid);
Expand Down
12 changes: 6 additions & 6 deletions OfficeIMO.Word/WordHyperLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ public static WordParagraph AddHyperLink(WordParagraph paragraph, string text, U

// Styling for the hyperlink
if (addStyle) {
//RunProperties runPropertiesHyperLink = new RunProperties(
// new RunStyle { Val = "Hyperlink", }
// //new Underline { Val = UnderlineValues.Single }
// //new Color { ThemeColor = ThemeColorValues.Hyperlink }
//);
//run.RunProperties = runPropertiesHyperLink;
RunProperties runPropertiesHyperLink = new RunProperties(
new RunStyle { Val = "Hyperlink", },
new Color { ThemeColor = ThemeColorValues.Hyperlink, Val = "0000FF" },
new Underline { Val = UnderlineValues.Single }
);
run.RunProperties = runPropertiesHyperLink;
}

if (tooltip != "") {
Expand Down