Aspose.Words does not identify hyperlink properly (missing URL)

Hi Aspose team,

I am using code from http://www.aspose.com/docs/display/wordsnet/How+to++Replace+or+Modify+Hyperlinks to process hyperlinks in Word document.

In attached test document (in BIN/Debug folder, Hyperlink.doc) you can find few links with TextToDisplay "G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Bestätigung Geheimhaltungspflicht.doc" but hyperlink behind this TextToDisplay is "\\nas2.winlan.net\g_6vb$\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Bestätigung Geheimhaltungspflicht.doc"

It looks like that code that you provided (where I am thankful) does not work properly as it returns as a hyperlink only TextToDisplay but cannot really find hyperlink.

Test project is attached.

Can you please review?

Thanks,
Oliver

Just to add - I tried also code from http://www.aspose.com/api/net/words/aspose.words.fields/fieldseparator

private static string GetFieldCode(FieldStart fieldStart)
{
StringBuilder builder = new StringBuilder();

for (Node node = fieldStart; node != null && node.NodeType != NodeType.FieldSeparator &&
node.NodeType != NodeType.FieldEnd; node = node.NextPreOrder(node.Document))
{
// Use text only of Run nodes to avoid duplication.
if (node.NodeType == NodeType.Run)
builder.Append(node.GetText());
}
return builder.ToString();
}

public void ReadHyperlinks()
{
// Specify your document name here.
Console.WriteLine("1." + DateTime.Now.ToString());
Aspose.Words.Document doc = new Aspose.Words.Document("hyperlink.doc");
Console.WriteLine("2." + DateTime.Now.ToString());
// Hyperlinks in a Word documents are fields, select all field start nodes so we can find the hyperlinks.
NodeList fieldStarts = doc.SelectNodes("//FieldStart");


foreach (FieldStart fieldStart in fieldStarts)
{

Console.WriteLine(GetFieldCode(fieldStart));

//if (fieldStart.FieldType.Equals(FieldType.FieldHyperlink))
//{
// // The field is a hyperlink field, use the "facade" class to help to deal with the field.
// Hyperlink hyperlink = new Hyperlink(fieldStart);

// // Some hyperlinks can be local (links to bookmarks inside the document), ignore these.
// if (hyperlink.IsLocal)
// continue;

//// The Hyperlink class allows to set the target URL and the display name
//// of the link easily by setting the properties.
//Console.WriteLine("1. Hyperlink Target: " + hyperlink.Target);
//Console.WriteLine("2. Hyperlink Name: " + hyperlink.Name);
//}
}
Console.WriteLine("3." + DateTime.Now.ToString());
}

And output is:



1.04.03.2016 23:08:21
2.04.03.2016 23:08:21
FILENAME \p
HYPERLINK "G:\\GBD_GES\\Handbuch\\SuchAnleitung.doc"
HYPERLINK "G:\\BBD_GES\\Handbuch\\1 Betriebliches\\Amtsgeheimnis\\Bestätigung Geheimhaltungspflicht.doc"
HYPERLINK "G:\\BBD_GES\\Handbuch\\1 Betriebliches\\Amtsgeheimnis\\Checkliste-Amtsgeheimnis.doc"
HYPERLINK "G:\\BBD_GES\\Handbuch\\1 Betriebliches\\Amtsgeheimnis\\Weisung Geheimhaltungspflicht.doc"
3.04.03.2016 23:08:21

So Hyperlinks.Target is totally skipped. Screenshot from Word attached.


Additional update - I tried also with FieldHyperlink but still same issue - URL is not recognized.
Coding was:

public void ReadHyperlinksNew()
{
Console.WriteLine("1." + DateTime.Now.ToString());
Aspose.Words.Document doc = new Aspose.Words.Document("hyperlink.doc");
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("Hyperlink.Address: " + hpl.Address);
Console.WriteLine("Hyperlink.Result: " + hpl.Result);
Console.WriteLine("Hyperlink.Target: " + hpl.Target);
Console.WriteLine("Hyperlink.SubAddress: " + hpl.SubAddress);
Console.WriteLine("Hyperlink.ScreenTip: " + hpl.ScreenTip);
Console.WriteLine("Hyperlink.GetFieldCode: " + hpl.GetFieldCode().ToString());
Console.WriteLine("=======================");
}
}

Output:

1.07.03.2016 15:07:20
2.07.03.2016 15:07:21
Hyperlink.Address: G:\GBD_GES\Handbuch\SuchAnleitung.doc
Hyperlink.Result: G:\BBD_GES\Handbuch\SuchAnleitung.doc
Hyperlink.Target:
Hyperlink.SubAddress:
Hyperlink.ScreenTip:
Hyperlink.GetFieldCode: HYPERLINK "G:\\GBD_GES\\Handbuch\\SuchAnleitung.doc"
=======================
Hyperlink.Address: G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Bestätigung Geheimhaltungspflicht.doc
Hyperlink.Result: G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Bestätigung Geheimhaltungspflicht.doc
Hyperlink.Target:
Hyperlink.SubAddress:
Hyperlink.ScreenTip:
Hyperlink.GetFieldCode: HYPERLINK "G:\\BBD_GES\\Handbuch\\1 Betriebliches\\Amtsgeheimnis\\Bestätigung Geheimhaltungspflicht.doc"
=======================
Hyperlink.Address: G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Checkliste-Amtsgeheimnis.doc
Hyperlink.Result: G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Checkliste-Amtsgeheimnis.doc
Hyperlink.Target:
Hyperlink.SubAddress:
Hyperlink.ScreenTip:
Hyperlink.GetFieldCode: HYPERLINK "G:\\BBD_GES\\Handbuch\\1 Betriebliches\\Amtsgeheimnis\\Checkliste-Amtsgeheimnis.doc"
=======================
Hyperlink.Address: G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Weisung Geheimhaltungspflicht.doc
Hyperlink.Result: G:\BBD_GES\Handbuch\1 Betriebliches\Amtsgeheimnis\Weisung Geheimhaltungspflicht.doc
Hyperlink.Target:
Hyperlink.SubAddress:
Hyperlink.ScreenTip:
Hyperlink.GetFieldCode: HYPERLINK "G:\\BBD_GES\\Handbuch\\1 Betriebliches\\Amtsgeheimnis\\Weisung Geheimhaltungspflicht.doc"
=======================

BR,
Oliver


Hi Oliver,

Thanks for your inquiry. We have tested the scenario and have noticed that Hyperlink address is not imported into Aspose.Words.Document. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-13240. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Any news here?

@dr_oli

We regret to share with you that the implementation of this issue has been postponed (no estimate is available at the moment). We will inform you via this thread as soon as this issue is resolved.

We apologize for your inconvenience.