Both hyperlinks in the Word document saved using Aspose .NET Word become linked, causing changes to one hyperlink to automatically update the other when edited in Trados Studio

Both hyperlinks in the Word document saved using Aspose .NET Word become linked, causing changes to one hyperlink to automatically update the other when edited in Trados Studio.

@fateh2024

It seems that you are experiencing an issue where hyperlinks in a Word document created with Aspose .NET are becoming linked, causing changes to one hyperlink to automatically update the other when edited in Trados Studio. This behavior typically occurs when the hyperlinks are treated as fields in the document.

To resolve this issue, you can unlink the fields in your document. Unlinking fields will convert them to plain text, preventing any automatic updates between them. Here’s how you can do this using Aspose.Words for .NET:

using Aspose.Words;

// Load the document
Document doc = new Document("path/to/your/document.docx");

// Unlink all fields in the document
doc.UnlinkFields();

// Save the modified document
doc.Save("path/to/your/modified_document.docx");

In this code snippet, the UnlinkFields method is called on the document object, which will unlink all fields, including hyperlinks, ensuring that they no longer update each other when edited.

If you need to selectively unlink only certain fields, you can iterate through the fields in the document and unlink them based on specific criteria.

This approach should help you manage the hyperlinks in your document effectively. If you have further questions or need additional assistance, feel free to ask!

In my test case, I copied and pasted an English text section containing hyperlinks for translation into another language, then hid the original section; however, when saving the Word document and translating in Trados Studio, the hyperlinks in both sections became dependent, causing changes in one to affect the other.

@fateh2024 Unfortunately, the problem is not clear enough. Could you please create a simple code and provide input and output documents that will allow us to reproduce the problem? We will check the issue and provide you more information.

testlinks3000.docx (10.8 KB)

I just added my test case file and this is my code .

Aspose.Words.Document doc = new Aspose.Words.Document(decodedInputPath);
doc.Save(decodedInputPath);

@fateh2024 I am afraid, it is still not clear how to reproduce the problem. As I can see in your document there are two pairs of links that uses the same target. After open/save using Aspose.Words the links still points to the same target the same way as in the source document.

@alexey.noskov You are right , but when we open this document(was processd by Aspose) in Trados Studio and change one link another link with same hyperlink is affected however if we do the same action with a word file without processing Aspose, it normally works and changing a link doesn’t effect another link with same hyperlink.

@alexey.noskov It looks like saveing in Aspose makes dependecies links with same hyperlink, or maybe Aspose add same bookmark over links with same hyperlink!!!

@fateh2024 Unfortunately, I do not see what might cause the problem. As I can see the links are stored the same way in both input and output documents. The actual links are defined in document.xml.rels like this:

<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\dev-appsettings-moulinsart.txt" TargetMode="External" />
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\test-doc-without-macro.doc" TargetMode="External" />

Then the links are used in the document.xml like this:

<w:hyperlink r:id="rId4" w:history="1">
.....
<w:hyperlink r:id="rId4" w:history="1">
.....
<w:hyperlink r:id="rId5" w:history="1">
.....
<w:hyperlink r:id="rId5" w:history="1">

I do not think the problem is in Aspose.Words. I think the problem should be reported to Trados Studio.

Also, as I can see, the document testlinks3000.docx you have attached was also generated by Aspose.Words 24.2 version. So the only change made after open/save of this document is the change in generated by comment.

@alexey.noskov I see size original file and save file in Aspose are not the equale.I attached original file and save file.
It looks, Aspose has reduced the size. is there anyway we prevent this in the code?

after-save-Apsose-testlinks.docx (10.8 KB)

Original-testlinks.docx (13.5 KB)

@fateh2024 When you open document using Aspose.Words, it read the whole document into Aspose.Words Document Object Model. When document is saved, Aspose.Words reconstructs the file from the DOM. So there is no way to preserve the file as is after processing the document using Aspose.Words.

@alexey.noskov I tested this scenario with MemoQ too, I get the same result as Trados Studio.
It looks Aspose save algorith makes this issue (changing a link make change in another link with same URL)

With orginal file MemoQ and Trados Studio , are OK , just exported file in Aspose has issue.

@alexey.noskov This is very critical for our company , we have license and we expect you fix this issue ASAP.

@alexey.noskov I understand what makes the problem .
I created Original-test.docs with two links and make After-save-Aspose-test.docs.
I realized the original file has two different Ids for hyper link :


BUT After-save-Aspose-test.docs which is exported from Aspose word .Net, has just one Id :

@fateh2024 The links are duplicated in document.xml.rels:

<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\test-doc-without-macro.doc" TargetMode="External"/>
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\dev-appsettings-moulinsart.txt" TargetMode="External"/>
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\dev-appsettings-moulinsart.txt" TargetMode="External"/>

So Aspose.Words writes the duplicated link as a single link.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27535

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks @alexey.noskov

1 Like

The issues you have found earlier (filed as WORDSNET-27535) have been fixed in this Aspose.Words for .NET 24.12 update also available on NuGet.

I’ve installed new version 24.12 and redid the test, the issue is not fixed and I have encountered the same issue.
The consequence of this issue is when we change a link by Apps like Trados or MemoQ, another link will be change automatically.

@fateh2024 I rechecked the scenario on my side with 24.12 version and duplicated links are written separately as expected:

<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\dev-appsettings-moulinsart.txt" TargetMode="External" />
<Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\dev-appsettings-moulinsart.txt" TargetMode="External" />
<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\test-doc-without-macro.doc" TargetMode="External" />
<Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="file:///C:\Users\fahmadi\Documents\test-doc-without-macro.doc" TargetMode="External" />

Did you use the same test document on your side? Could you please attach your input and output documents here for our reference?