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);