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

Free Support Forum - aspose.com

Replacement of URL (UNC) is losing \ and breaking links

Hi Aspose team,

I am testing replacement of hyperlinks in Word documents. By using following code after replacement links are broken:

public void ReplaceHyperlinksNew()
{
Console.WriteLine("1." + DateTime.Now.ToString());
Aspose.Words.Document doc = new Aspose.Words.Document("UNCHyperlinks.docx");
Console.WriteLine("2." + DateTime.Now.ToString());

foreach (Field field in doc.Range.Fields)
{
if (field.Type.Equals(FieldType.FieldHyperlink))
{
FieldHyperlink hpl = (FieldHyperlink)field;
Console.WriteLine("1. Hyperlink: " + hpl.Address);
hpl.Address = hpl.Address.Replace(OldUrl,NewUrl);
hpl.Result = hpl.Result.Replace("NewUrl", "NewName");
Console.WriteLine("2. Hyperlink: " + hpl.Address);
}
}
Console.WriteLine("3." + DateTime.Now.ToString());
doc.Save("output111.docx");
Console.WriteLine("4." + DateTime.Now.ToString());
}

private const string OldUrl = @"\\sion-n08\usr\DATA\EPV\GROUP\";
private const string NewUrl = @"\\infra.vs.ch\dfs\SAPEM-DSMV\";
private const string NewName = @"\\infra.vs.ch\dfs\SAPEM-DSMV\";

Expected result is \\infra.vs.ch\dfs\SAPEM-DSMV\ but real result is \infra.vs.chdfsSAPEM-DSMV

Can you please check?

Sample project and test document are attached.

Thanks,
Oliver

Hi Oliver,


Thanks for your inquiry. While using the latest version of Aspose.Words i.e. 16.1.0, we managed to reproduce this issue on our end. We have logged this issue in our bug tracking system. The ID of this issue is WORDSNET-13246. Your thread has also been linked to this issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-13246) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan