We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Words is adding \ in hyperlinks

Hi Aspose team,

when I try to process attached document with hyperlinks like:

\WAIS-SRV1\FDRIVE\dms\corporate services\administration\operational\shared\wais netball selection criteria v 1.1.docx

Aspose code is reporting that link is:

\WAIS-SRV1\FDRIVE\dms\corporate services\administration\operational\shared\wais netball selection criteria v 1.1.docx

Sample project and test document are attached.

Can you please have a look?

Thanks,

Oliver

Hi Oliver,

Thanks for your inquiry.

We have tested the scenario using latest version of Aspose.Words for .NET 15.10.0 and have not found the shared issue. See the attached image for detail. Please use Aspose.Words for .NET 15.10.0. We have attached the output document with this post for your kind reference.

Hello,

this is exactly the problem.

Hyperlinks are properly saved in document but when Aspose Hyperlinks class (https://docs.aspose.com/words/net/working-with-fields/)

does not work properly as it adds \ in UNC links.

For example, when I run attached project over same document that you create (output.docx) if I put breakpoint on

hyperlink.Target = hyperlink.Target.Replace(NewUrl, NewName);

you can see in attached image that \\ are shown.

I fixed this problem for my scenario but it will be good that you adjust Hyperlink class coding in https://docs.aspose.com/words/net/working-with-fields/

BR,
Oliver

Hi Oliver,

Thanks for your inquiry. The hyperlink in your document contains the \\ at the start of link. Please check the attached image for detail. Open the document in MS Word and put the cursor at the place of hyperlink and press Alt + F9 to see the hyperlink field’s codes.

Please let us know if you have any more queries.

Hi Tahir,

if you open this document and the go to Edit Hyperlink you will see that it has \.

See image.

\\ are reported by Aspose Hyperlink class.

BR,

Oliver

Hi Oliver,

Thanks for your inquiry. A field in a Word document is a complex structure consisting of multiple nodes that include field start, field code, field separator, field result and field end. Fields can be nested, contain rich content and span multiple paragraphs or sections in a document. The Field class is a “facade” object that provides properties and methods that allow to work with a field as a single object.

The Start, Separator and End properties point to the field start, separator and end nodes of the field respectively.

The content between the field start and separator is the field code. The content between the field separator and field end is the field result. The field code typically consists of one or more Run objects that specify instructions. The processing application is expected to execute the field code to calculate the field result.

Please note that this is not an issue. Your query is related to Escape Sequences. Character combinations consisting of a backslash () followed by a letter or by a combination of digits are called “escape sequences.”

In your case you are checking the backslashes in watch window. In the watch window, single \ will be shown as \. See the attached image (Escape Sequences.png) for detail. Following string’s value is shown in attached image.

If you insert simple hyperlink to a file in Word document \ will be inserted in the field’s codes. E.g {HYPERLINK “C:\Users\admin\Desktop\document.txt”}. Please press Alt + F9 in MS Word to see the field’s code of hyperlink.

String link = @"\WAIS-SRV1\FDRIVE\dms\corporate services\administration\operational\shared\wais netball selection criteria v 1.1.docx";

Console.WriteLine(link);

Moreover, we suggest you please check the link’s value in Text Visualizer. You will see the same link value in Text Visualizer as shown in MS Word. Please press Alt + F9 in MS Word to see the field’s code. See the attached ‘Text Visualizer.png’ for detail.

Hope this answers your query. Please let us know if you have any more queries.