Link
Wraps any layout content in a clickable hyperlink. The link is active in PDF viewers that support annotations. In a PDF/X document, made for a printer, links print their content and are not clickable.
Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
href |
URL | — | Required. Link destination: a URL, or #id to jump to the bookmark with that id |
data-href |
string | — | Dot-path: sets href from the data. See Attributes from data |
gap |
spacing | — | Gap between child elements |
ocg |
string | — | print or screen: shown only in print, or only on screen. See Print and screen content |
Text link
Section titled “Text link”<link href="https://lpdf.io"> <text color="#1a73e8" font-size="m">Visit lpdf.io</text></link>L.link({ href: 'https://lpdf.io' }, [ L.text({ color: '#1a73e8', fontSize: 'm' }, ['Visit lpdf.io']),])L.link(LinkAttr(href='https://lpdf.io'), [ L.text(TextAttr(color='#1a73e8', font_size='m'), ['Visit lpdf.io'])])L.link(new LinkAttr().href("https://lpdf.io"), List.of( L.text(new TextAttr().color("#1a73e8").fontSize("m"), List.of("Visit lpdf.io"))))L.Link(new() { Href = "https://lpdf.io" }, [ L.Text(new() { Color = "#1a73e8", FontSize = "m" }, ["Visit lpdf.io"]),])L::link(new LinkAttr(href: 'https://lpdf.io'), [ L::text(new TextAttr(color: '#1a73e8', fontSize: 'm'), ['Visit lpdf.io']),])Image link
Section titled “Image link”<link href="https://lpdf.io"> <img name="logo" width="80pt"/></link>L.link({ href: 'https://lpdf.io' }, [ L.img({ name: 'logo', width: '80pt' }),])L.link(LinkAttr(href='https://lpdf.io'), [ L.img(ImgAttr(name='logo', width='80pt'))])L.link(new LinkAttr().href("https://lpdf.io"), List.of( L.img(new ImgAttr().name("logo").width("80pt"))))L.Link(new() { Href = "https://lpdf.io" }, [ L.Img(new() { Name = "logo", Width = "80pt" }),])L::link(new LinkAttr(href: 'https://lpdf.io'), [ L::img(new ImgAttr(name: 'logo', width: '80pt')),])Link to a bookmark
Section titled “Link to a bookmark”# and a bookmark’s id jump to that bookmark, in the same PDF.
<column gap="m"> <link href="#terms"> <text color="#1a73e8">Read the terms</text> </link> <bookmark label="Terms" id="terms"/> <text font-size="l">Terms</text></column>L.column({ gap: 'm' }, [ L.link({ href: '#terms' }, [ L.text({ color: '#1a73e8' }, ['Read the terms']), ]), L.bookmark({ label: 'Terms', id: 'terms' }), L.text({ fontSize: 'l' }, ['Terms']),])L.column(ColumnAttr(gap='m'), [ L.link(LinkAttr(href='#terms'), [ L.text(TextAttr(color='#1a73e8'), ['Read the terms']) ]), L.bookmark(BookmarkAttr(label='Terms', id='terms')), L.text(TextAttr(font_size='l'), ['Terms'])])L.column(new ColumnAttr().gap("m"), List.of( L.link(new LinkAttr().href("#terms"), List.of( L.text(new TextAttr().color("#1a73e8"), List.of("Read the terms")) )), L.bookmark(new BookmarkAttr().label("Terms").id("terms")), L.text(new TextAttr().fontSize("l"), List.of("Terms"))))L.Column(new() { Gap = "m" }, [ L.Link(new() { Href = "#terms" }, [ L.Text(new() { Color = "#1a73e8" }, ["Read the terms"]), ]), L.Bookmark(new() { Label = "Terms", Id = "terms" }), L.Text(new() { FontSize = "l" }, ["Terms"]),])L::column(new ColumnAttr(gap: 'm'), [ L::link(new LinkAttr(href: '#terms'), [ L::text(new TextAttr(color: '#1a73e8'), ['Read the terms']), ]), L::bookmark(new BookmarkAttr(label: 'Terms', id: 'terms')), L::text(new TextAttr(fontSize: 'l'), ['Terms']),])A link to an id that no bookmark has is left out of the PDF: its content is drawn, but it is not clickable. In a table of contents, href="#" alone jumps to the bookmark of the entry it is in.
Data binding
Section titled “Data binding”data-href sets the destination from the data, and href is what stays when no data is passed or the path has no value. Text inside the link can be bound too. See Attributes from data.
<link href="https://example.com" data-href="product.url"> <text data-value="product.name" color="#1a73e8">Product</text></link>data-value does not change href.