Text (canvas)
Absolutely positioned text. Unlike flow text, canvas text does not participate in layout and will not paginate — it is rendered at the exact coordinates you specify. It does not inherit the document’s font or size.
Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
x |
signed pt | — | X position (or offset from anchor) |
y |
signed pt | — | Y position (or offset from anchor) |
anchor |
string | — | Reference point |
font |
string | Helvetica |
Font name: a built-in font or one declared in assets |
font-size |
pt | 12pt |
Font size. A token such as m is not accepted here; mm and in are |
color |
color | #000000 |
Text color |
align |
string | left |
left center right justify |
w |
pt | — | Text wrap width. Without it, text wraps at the right edge of the page |
line-height |
number | 1.2 |
Line height multiplier |
opacity |
0–1 | 1 | Opacity |
Either anchor or both x and y must be provided.
Page footer on every page
Section titled “Page footer on every page”<canvas> <layer page="each"> <text anchor="bottom-center" y="-18pt" font-size="9pt" color="#aaaaaa" align="center"> lpdf.io — Confidential </text> </layer></canvas>L.canvas(NoAttr, [ L.layer({ page: 'each' }, [ L.textAt({ anchor: 'bottom-center', y: '-18pt', fontSize: '9pt', color: '#aaaaaa', align: 'center' }, ['lpdf.io — Confidential']), ]),])L.canvas(NoAttr, [ L.layer(LayerAttr(page='each'), [ L.text_at(CanvasTextAttr(anchor='bottom-center', y='-18pt', font_size='9pt', color='#aaaaaa', align='center'), ['lpdf.io — Confidential']) ])])L::canvas(NoAttr, [ L::layer(new LayerAttr(page: 'each'), [ L::textAt(new CanvasTextAttr(anchor: 'bottom-center', y: '-18pt', fontSize: '9pt', color: '#aaaaaa', align: 'center'), ['lpdf.io — Confidential']), ]),])L.Canvas(NoAttr, [ L.Layer(new() { Page = "each" }, [ L.TextAt(new() { Anchor = "bottom-center", Y = "-18pt", FontSize = "9pt", Color = "#aaaaaa", Align = "center" }, ["lpdf.io — Confidential"]), ]),])Canvas text is not data-bound, and the page number placeholders work only in the text of a layout region. For a footer with the page number, use a region.
DRAFT watermark (rotated via layer transform)
Section titled “DRAFT watermark (rotated via layer transform)”<canvas> <layer page="each" opacity="0.1" transform="rotate(45, 306, 396)"> <text x="50pt" y="420pt" font-size="80pt" color="#cc0000">DRAFT</text> </layer></canvas>L.canvas(NoAttr, [ L.layer({ page: 'each', opacity: '0.1', transform: 'rotate(45, 306, 396)' }, [ L.textAt({ x: '50pt', y: '420pt', fontSize: '80pt', color: '#cc0000' }, ['DRAFT']), ]),])L.canvas(NoAttr, [ L.layer(LayerAttr(page='each', opacity='0.1', transform='rotate(45, 306, 396)'), [ L.text_at(CanvasTextAttr(x='50pt', y='420pt', font_size='80pt', color='#cc0000'), ['DRAFT']) ])])L::canvas(NoAttr, [ L::layer(new LayerAttr(page: 'each', opacity: '0.1', transform: 'rotate(45, 306, 396)'), [ L::textAt(new CanvasTextAttr(x: '50pt', y: '420pt', fontSize: '80pt', color: '#cc0000'), ['DRAFT']), ]),])L.Canvas(NoAttr, [ L.Layer(new() { Page = "each", Opacity = "0.1", Transform = "rotate(45, 306, 396)" }, [ L.TextAt(new() { X = "50pt", Y = "420pt", FontSize = "80pt", Color = "#cc0000" }, ["DRAFT"]), ]),])Inline spans for mixed styling
Section titled “Inline spans for mixed styling”span children work like those in flow text, but only font and color are read:
<canvas> <layer> <text x="40pt" y="60pt" font-size="11pt"> Invoice <span color="#1a73e8">#1042</span> </text> </layer></canvas>L.canvas(NoAttr, [ L.layer(NoAttr, [ L.textAt({ x: '40pt', y: '60pt', fontSize: '11pt' }, [ 'Invoice', L.span({ color: '#1a73e8' }, ['#1042']), ]), ]),])L.canvas(NoAttr, [ L.layer(NoAttr, [ L.text_at(CanvasTextAttr(x='40pt', y='60pt', font_size='11pt'), [ 'Invoice', L.span(SpanAttr(color='#1a73e8'), ['#1042']) ]) ])])L::canvas(NoAttr, [ L::layer(NoAttr, [ L::textAt(new CanvasTextAttr(x: '40pt', y: '60pt', fontSize: '11pt'), [ 'Invoice', L::span(new SpanAttr(color: '#1a73e8'), ['#1042']), ]), ]),])L.Canvas(NoAttr, [ L.Layer(NoAttr, [ L.TextAt(new() { X = "40pt", Y = "60pt", FontSize = "11pt" }, [ "Invoice", L.Span(new() { Color = "#1a73e8" }, ["#1042"]), ]), ]),])