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

Free Support Forum - aspose.com

Problem converting hyperlinks to DOCX format

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We are using DOC to DOCX conversion functionality provided by Aspose.Word.java toolkit. We noticed that hyperlinks in WORD2003 document are represented using HYPERLINK field in DOCX format as shown below.

<w:p w:rsidR="00BF15D3" w:rsidP="00BF15D3">

<w:fldChar w:fldCharType="begin" />

</w:r>

<w:r w:rsidR="00773FAD">

<w:instrText xml:space="preserve">HYPERLINK "http://www.google.com/" \h </w:instrText>

</w:r>

<w:fldChar w:fldCharType="separate" />

</w:r>

<w:r w:rsidR="00773FAD">

Link to G</w:t>

</w:r>

<w:bookmarkStart w:id="6" w:name="_Hlt192994867" />

<w:r w:rsidR="00773FAD">

o</w:t>

</w:r>

<w:bookmarkEnd w:id="6" />

<w:r w:rsidR="00773FAD">

og</w:t>

</w:r>

<w:bookmarkStart w:id="7" w:name="_Hlt192994885" />

<w:r w:rsidR="00773FAD">

l</w:t>

</w:r>

<w:bookmarkEnd w:id="7" />

<w:r w:rsidR="00773FAD">

e.com</w:t>

</w:r>

<w:fldChar w:fldCharType="end" />

</w:r>

</w:p>

As per open XML standard, hyperlinks should be represented using hyperlink element as shown below. I confirmed the same by manually converting a word2003 document to DOCX format using MS word convertor.

<w:p w:rsidR="005D62B1" w:rsidRPr="00FE5428" w:rsidRDefault="005D62B1" w:rsidP="00001DFC">

<w:b />

<w:sz w:val="28" />

<w:szCs w:val="28" />

<w:u w:color="FFFF00" />

</w:rPr>

</w:pPr>

<w:hyperlink r:id="rId11" w:history="1">

<w:r w:rsidRPr="005D62B1">

<w:rStyle w:val="Hyperlink" />

<w:b />

<w:sz w:val="28" />

<w:szCs w:val="28" />

<w:u w:color="FFFF00" />

</w:rPr>

Link to Google.com</w:t>

</w:r>

</w:hyperlink>

</w:p>

1 Like

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I will consult with our developers and provide you more information.

Best regards.

Good question.

I don't see anything in the OOXML specification that says the should or must be used over the HYPERLINK field. Both the w:hyperlink element and HYPERLINK field are valid as far as I can tell. In fact, there are hyperlinks possible that canot be represented using , but can be represented using a HYPERLINK field. For example a hyperlink that includes one or more paragraph breaks.

On one hand, I agree it could be a useful optimization in Aspose.Words that it would write out instead of a HYPERLINK field when it is possible because an XML element might be easier for other OOXML consumers to parse. But on the other hand it is a problem of the other consumer application to support as much of the complexities of the OOXML standard as it could.

I will log this as an enhancement, but I cannot promise a timeframe at this stage unless you point out I'm wrong with understanding of the standard.

By the way, when importing DOCX, Aspose.Words will read both and HYPERLINK properly.