Created
January 29, 2025 14:59
Aspose.Words for .NET. Working with hyperlinks using C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
builder.Write("Please make sure to visit "); | |
builder.Font.Style = doc.Styles[StyleIdentifier.Hyperlink]; | |
builder.InsertHyperlink("Aspose Website", "http://www.aspose.com", false); | |
builder.Font.ClearFormatting(); | |
builder.Write(" for more information."); | |
doc.Save(ArtifactsDir + "AddContentUsingDocumentBuilder.InsertHyperlink.docx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Hyperlinks.docx"); | |
foreach (Field field in doc.Range.Fields) | |
{ | |
if (field.Type == FieldType.FieldHyperlink) | |
{ | |
FieldHyperlink hyperlink = (FieldHyperlink) field; | |
// Some hyperlinks can be local (links to bookmarks inside the document), ignore these. | |
if (hyperlink.SubAddress != null) | |
continue; | |
hyperlink.Address = "http://www.aspose.com"; | |
hyperlink.Result = "Aspose - The .NET & Java Component Publisher"; | |
} | |
} | |
doc.Save(ArtifactsDir + "WorkingWithFields.ReplaceHyperlinks.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment