In the attached example word file, there are 2 hyperlinks. "http://www.website2.com" and "http://wwW.webSite1.COM". One in lowercase and one with mixed case.
When I change the first URI from "http://www.website2.com" to "http://www.website1.com", the capitalization of the second URI changes also.
I do this by setting a new value to the FieldHyperlink.Address property.
Thanks for your inquiry. We have tested the scenario using the latest version of Aspose.Words for .NET 19.1 with your code example and have not found the shared issue. Could you please share your problematic and expected output documents here for our reference? We will then provide you more information about your query.
The problem does exist in Aspose.Words for .NET 19.1.
In the example word file attached to first post there are 2 hyperlinks.
1.) http://www.website2.com/
2.) http://www.webSite1.COM/ <-- notice the capitalisation
if you use Aspose.Words to change link 1 to http://www.website.com/ (the same as link 2, but all lower case), then the character casing of link 2. changes as well.
I need to be able to change one link without the character casing of the other one changing.
Thanks for your inquiry. We have tested again your scenario and noticed that only the field (http://www.website2.com/) is changed in output document. Please check the attached images for detail.
We suggest you please use the following modified code snippet.
If you still face problem, please ZIP and attach your problematic and expected output Word documents here for our reference. We will investigate how you want your final Word output be generated like and provide you more information about your query along with code.
PS : You can create your expected output document using Microsoft Word.
The word document may appear like this, but the values during execution are as I have described, and as demonstrated by the VS project I attached previously.
Look at the attached image for the values during code execution:
Thanks for your inquiry. We tested the scenario using the latest version of Aspose.Words for .NET 19.1 and have not found the shared issue. Please check the attached image for detail and use Aspose.Words for .NET 19.1.
Thanks for your inquiry. In my previous post, the screenshot shows the output of your code. You can also test this case by using following code example.
Document doc = new Document(MyDir + "links.docx");
foreach (Field field in doc.Range.Fields)
{
if (field.Type == FieldType.FieldHyperlink)
{
FieldHyperlink hyperlink = (FieldHyperlink)field;
if (hyperlink.Address == null) return;
if (hyperlink.Address.Contains(@"website2.com"))
{
hyperlink.Address = hyperlink.Address.Replace("website2.com", "website1.com");
hyperlink.Result = hyperlink.Address;
Console.WriteLine("After replacing the Address is : ");
Console.WriteLine($"\t{hyperlink.Address}");
}
}
}
Console.WriteLine("Print the address");
foreach (Field field in doc.Range.Fields)
{
if (field.Type == FieldType.FieldHyperlink)
{
FieldHyperlink hyperlink = (FieldHyperlink)field;
if (hyperlink.Address == null) return;
Console.WriteLine($"\t{hyperlink.Address}");
}
}
doc.Save(MyDir + "19.1.docx");
Console.WriteLine("After saving the document.");
Document doc2 = new Document(MyDir + "19.1.docx");
foreach (Field field in doc2.Range.Fields)
{
if (field.Type == FieldType.FieldHyperlink)
{
FieldHyperlink hyperlink = (FieldHyperlink)field;
if (hyperlink.Address == null) return;
Console.WriteLine($"\t{hyperlink.Address}");
}
}
We have attached the screenshot of output. Please let us know if you have any more queries.
Thanks for your inquiry. Please make sure that you are using the same Word document and latest version of Aspose.Words for .NET 19.1. Moreover, please try the code example share in my previous post.
We have downloaded the same input document from your first post and tested the scenario at same environment. We have not found any issue with output. We have attached the screenshot of output for your kind reference.