Set hyperlink in image object

Hi!
I searched without any result for the option to set hyperlink on inserted image (while new document creation). MS Word has such option for pictures, clip arts and shapes, does Aspose ?
Thank you,
Yulia, Cellebrite software developer.

Hi Yulia,

Thanks for your inquiry. You can easily achieve this using Aspose.Words by setting ShapeBase.HRef property. Please use following code snippet for your requirements and let us know if you have any more queries.

// Create document and DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert image, which will be a hyperlink.
Shape shape = builder.InsertImage(@"Common\test.jpg");
// We should set HRef property of shape to make it a hyperlink.
// HRef will be a bookmark in the document, which wil be inserted later.
string bookmarkName = "myBookmark";
shape.HRef = string.Format("#{0}", bookmarkName);
// Insert few page breaks and bookmark.
builder.InsertBreak(BreakType.PageBreak);
builder.InsertBreak(BreakType.PageBreak);
// Insert bookmark.
builder.StartBookmark(bookmarkName);
builder.Write("This is some text");
builder.EndBookmark(bookmarkName);
// Save output document.
doc.Save(@"Test001\out.doc");
// Create document and DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert image, which will be a hyperlink.
Shape shape = builder.InsertImage(@"d:\Aspose.jpg");
shape.HRef = "http://www.aspose.com";
doc.Save(MyDir + "AsposeOut.docx");