Could you tell me how to insert an image hyperlink in Aspose.Words ? i.e I have to insert an image into the document and set a hyperlink to it, whereby “Ctrl + Clicking on the image takes me to the URL specified in the hyperlink.”
Thanks for your inquiry. You can achieve this by using the ShapeBase.HRef property; for example, please try run the following code snippet. This code inserts a click able (Hyperlinked) image in Word document:
DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.InsertImage(@"C:\Temp\Aspose.Words.png"); shape.HRef = "http://www.aspose.com/images/aspose-logo.gif"; builder.Document.Save(@"C:\Temp\out.docx");
I hope, this helps.
Hi Awais Hafeez**,**
Thanks for the reply.I tried the obove code, but could not find the HRef property under Shape. Is it available in Aspose.Words for JAVA ?
Thanks for your inquiry. Sure, here is the Java equivalent code:
DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.insertImage("C:\Temp\Aspose.Words.png"); shape.setHRef("http://www.aspose.com/images/aspose-logo.gif"); builder.getDocument().save("C:\Temp\out.docx");
Please let me know if I can be of any further assistance.
Hi Awais Hafeez,
Thank you so much for the reply. It is woring fine now. I was searching for the option in an older jar and thus the issue.
Thanks for your feedback. In case you have further inquires or need any help, please let us know.