href property

ShapeBase.href property

Gets or sets the full hyperlink address for a shape.

@property
def href(self) -> str:
    ...

@href.setter
def href(self, value: str):
    ...

Remarks

The default value is an empty string.

Below are examples of valid values for this property:

Full URI: https://www.aspose.com/.

Full file name: C:\\\\My Documents\\\\SalesReport.doc.

Relative URI: ../../../resource.txt

Relative file name: ..\\\\My Documents\\\\SalesReport.doc.

Bookmark within another document: https://www.aspose.com/Products/Default.aspx#Suites

Bookmark within this document: #BookmakName.

Examples

Shows how to insert a shape which contains an image, and is also a hyperlink.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
shape = builder.insert_image(file_name=IMAGE_DIR + 'Logo.jpg')
shape.href = 'https://forum.aspose.com/'
shape.target = 'New Window'
shape.screen_tip = 'Aspose.Words Support Forums'
# Ctrl + left-clicking the shape in Microsoft Word will open a new web browser window
# and take us to the hyperlink in the "HRef" property.
doc.save(file_name=ARTIFACTS_DIR + 'Image.InsertImageWithHyperlink.docx')

See Also