hyperlink_base property

Specifies the base string used for evaluating relative hyperlinks in this document.

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

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

Remarks

Aspose.Words does not use this property.

Examples

Shows how to store the base part of a hyperlink in the document’s properties.

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Insert a relative hyperlink to a document in the local file system named "Document.docx".
# Clicking on the link in Microsoft Word will open the designated document, if it is available.
builder.insert_hyperlink('Relative hyperlink', 'Document.docx', False)
# This link is relative. If there is no "Document.docx" in the same folder
# as the document that contains this link, the link will be broken.
self.assertFalse(system_helper.io.File.exist(ARTIFACTS_DIR + 'Document.docx'))
doc.save(file_name=ARTIFACTS_DIR + 'DocumentProperties.HyperlinkBase.BrokenLink.docx')
# The document we are trying to link to is in a different directory to the one we are planning to save the document in.
# We could fix links like this by putting an absolute filename in each one.
# Alternatively, we could provide a base link that every hyperlink with a relative filename
# will prepend to its link when we click on it.
properties = doc.built_in_document_properties
properties.hyperlink_base = MY_DIR
self.assertTrue(system_helper.io.File.exist(properties.hyperlink_base + doc.range.fields[0].as_field_hyperlink().address))
doc.save(file_name=ARTIFACTS_DIR + 'DocumentProperties.HyperlinkBase.WorkingLink.docx')

See Also