I'm developing an application where a report needs to be generated in both docx and pdf format.
The report is generated from a docx tempate, where specific text placeholders are replaced with the actual text.
I also need to add some hyperlinks (not http, nor mailto, but a custom URI) and right now the code that does this is roughly the following:
- Code: Select all
if(isPlaceholderFound)
{
paragraph.Text = "";
paragraph.AppendHyperlink("myProtocol://path?key1=val1&key2=val2", "My Text", HyperlinkType.WebLink);
}
Unfortunately, no matter what kind of HyperLink type I use, the custom URI is not recognized and so the output document doesn't contain a valid uri.
Both docx and pdf support this feature (If I manually add the custom URI to my docx document, it works as expected)
I also tried the following things:
1- Using
- Code: Select all
paragraph.AppendHTML("<h1><a href='myProtocol://path?key1=val1&key2=val2'>My Text</a></h1>");
instead of AppendHyperLink produces the same result. (HTML is correctly parsed as the h1 tag makes the text bigger, but the hyperlink still has the wrong link)
2- Changing HyperlinkType.WebLink to HyperlinkType.None or other values produce the same result.
More info about my setup:
- Everything is developed in .net Framework 4.8 and is run on Windows 10 Pro 64 bit (19045.2965) region set in Italian.
- I'm actually using the latest versions of Spire.doc (trial license) (11.5.12.3040) downloaded from Nuget.
- The code is inside a Library project (.dll) built as any cpu (it is then run inside a WPF application and a console app, the results are the same).
I'd really like to use this library buying the PRO version as it is very powerful and easy to use, but I really need to include these hyperlinks inside it.
Does anyone have an idea about why this strange behaviour happens?
Many thanks in advance!