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

Free Support Forum - aspose.com

Pound sign in hyperlink gets mis-translated on import

If you load the attached document into the Document Explorer sample app, you will see that the hyperlink url is given as
HYPERLINK "http://www.quicktopic.com/faq.html" \l "abc"
It should be
HYPERLINK "<http://www.quicktopic.com/faq.html#abc"
Thanks,
Steve

Hi Steve,
Thanks for your request. This is correct value. You see field code/ if you press Alt+F9 in MS Word you will see the same value. Here is field code:
{ HYPERLINK "http://www.quicktopic.com/faq.html" \l "abc" }
Best regards.

Thank you. Can you suggest how to decode it to restore the original value?

Hi
Thanks for your request. You can try just replace " \l " with #. Please see the following code example:

Document doc = new Document(@"Test192\in.docx");
//Get collection of field starts
NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart, true);
//Create string that will contain links
string links = string.Empty;
//Create regex for parsing field code
Regex regex = new Regex(@"HYPERLINK (?.*)");
//loop through all field starts
foreach (FieldStart start in starts)
{
    if (start.FieldType == FieldType.FieldHyperlink)
    {
        string fieldCode = string.Empty;
        Node currNode = start.NextSibling;
        while (currNode.NodeType != NodeType.FieldSeparator)
        {
            fieldCode += (currNode as Run).Text;
            currNode = currNode.NextSibling;
        }
        Match match = regex.Match(fieldCode);
        links += match.Groups["value"].Value.Replace("\" \\l \"", "#") + "\n";
    }
}
Console.Write(links);

Hope this helps.
Best regards.

Nevermind, I’ve got it.
Thanks,
Steve

Ah, I hadn’t seen your code example when I posted the last message. It looks useful. Thank you!
Steve