Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jun 06, 2023 11:15 am

Hello,
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!

PaolaDeMaria
 
Posts: 1
Joined: Wed May 31, 2023 11:44 am

Wed Jun 07, 2023 7:15 am

Hello,

Thank you for your inquiry.
Based on the information you provided, we cannot access your custom hyperlinks. In order to help us investigate and solve your problem quickly and effectively, please provide your Word document (where you manually added the URLs and they can be linked correctly). You could attach it here or send it to us via email ([email protected]). Thanks in advance.

Sincerely
Wenly
E-iceblue support team
User avatar

Wenly.Zhang
 
Posts: 149
Joined: Tue May 16, 2023 2:19 am

Return to Spire.Doc