I have a requirement which needs to create a list of hyperlinks dynamically in a Word document. The list can have one or more hyperlinks and I won’t know the number of links until runtime. Basically, the list looks like a bullet list and each item is a hyperlink. How do you create this kind of list in Aspose.Words? Do you have any sample code to handle this scenario?
Attached is a desired result list which I need to create.
DynamicHyperlinks.jpg (29.3 KB)
Thanks!
Tiffany
@humanamhs
Thanks for your inquiry. Please check following code snippet, it will help you to create Hyperlink List in Word document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.Writeln("Hyperlink List example:");
builder.ListFormat.List = doc.Lists.Add(ListTemplate.NumberDefault);
builder.ListFormat.ListLevel.NumberFormat = "-";
builder.Font.Color = Color.Blue;
builder.Font.Underline = Underline.Single;
builder.InsertHyperlink("Aspose", "https://www.aspose.com", false);
builder.Writeln();
builder.InsertHyperlink("Goolge", "https://www.google.com", false);
builder.Writeln();
builder.ListFormat.RemoveNumbers();
doc.Save("Listout.docx");