v4.4.0. A link is a run format, like bold or italic: any span of text can carry one. Two kinds exist:
http://…, https://… or mailto:…. A bare domain
(example.com/menu) is normalized to https://.#<anchor_id>, pointing at a link target
(an anchor): a named span marked elsewhere in the document. Following it
jumps to the target’s page and selects the span.from edof import Document
from edof.format.styles import TextRun
doc = Document()
p1 = doc.add_page(); p2 = doc.add_page()
tb = p1.add_textbox(10, 10, 100, 12, "")
tb.runs = [
TextRun(text="Visit the site", link="https://example.com"),
TextRun(text=" or jump to the "),
TextRun(text="glossary", link="#anch_glossary"),
]
tgt = p2.add_textbox(10, 10, 100, 12, "")
tgt.runs = [TextRun(text="Glossary", anchor="anch_glossary",
anchor_name="Glossary")]
| Field | On | Meaning |
|---|---|---|
link |
TextRun |
External URL or #<anchor_id>; None = plain text |
anchor |
TextRun |
Stable target id (like a rid, survives editing around it) |
anchor_name |
TextRun |
Human name shown in pickers |
link_style |
Document |
Document-wide link appearance (below) |
All fields are optional format keys (format 4.3.0); old readers ignore them.
Links render with the document link style unless a run overrides
color / underline explicitly — that is how one specific link is
re-styled by normal formatting.
doc.link_style = {
"color": (17, 85, 204, 255), # base colour (default: blue)
"underline": True,
"hover_color": (11, 57, 158, 255), # editor hover tint
}
None (the default) uses the built-in blue-underlined style. In the editor:
Document → Link style… edits it for every link at once.
Link targets are validated everywhere — on creation, on follow and on
export — against a whitelist: http, https, mailto and #anchor.
javascript:, file:, data: and free text are refused;
set_link_on_selection() returns False for them. A link stored in an
untrusted file cannot smuggle a dangerous scheme, because following
re-validates. See edof.utils.links.validate_link.
/Link annotation: external targets as
/A /URI actions, in-document targets as /Dest [page /Fit] resolved to
the target’s page. Adjacent same-link words on a line merge into one
clickable rectangle.<a href … xlink:href …> (external
links open in a new tab).Unsafe or dead targets are silently skipped by the exporters.