in attached project you will find simple code that is going through Document.doc and make change of hyperlink with target containing H: to U:. Original file size is 22528 bytes and new document is 11776.
Im selben Verzeichnis: HYPERLINK “DataSheet.xlsx” DataSheet.xlsx
In Laufwerk H: HYPERLINK “file:///H:\DataSheet.xlsx” H:\DataSheet.xlsx
In Laufwerk H: mit alternativem Text: HYPERLINK “file:///H:\DataSheet.xlsx” The Data
Changed document has:
I m s e l b e n V e r z e i c h n i s : H Y P E R L I N K " D a t a S h e e t . x l s x " D a t a S h e e t . x l s x
I n L a u f w e r k H : H Y P E R L I N K U : \ \ D a t a S h e e t . x l s x H : \ D a t a S h e e t . x l s x
I n L a u f w e r k H : m i t a l t e r n a t i v e m T e x t : H Y P E R L I N K U : \ \ D a t a S h e e t . x l s x T h e D a t a
Thanks for your inquiry. Aspose.Words optimizes the output document. However, there is no issue with output DOC file. Moreover, we suggest you please use FieldHyperlink.Address property as shown below to set a location where hyperlink jumps.
Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "document.doc");
NodeList fieldStarts = doc.SelectNodes("//FieldStart");
foreach (FieldStart fieldStart in fieldStarts)
{
if (fieldStart.FieldType.Equals(FieldType.FieldHyperlink))
{
// The field is a hyperlink field, use the "facade" class to help to deal with the field.
FieldHyperlink hyperlink = (FieldHyperlink)fieldStart.GetField();
if (hyperlink.Address.Contains(@"H:"))
{
hyperlink.Address = hyperlink.Address.Replace("H:", "U:");
}
}
}
DocSaveOptions options = new DocSaveOptions();
options.SaveFormat = SaveFormat.Doc;
doc.Save(MyDir + "18.7.doc", options);
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.