Slates
Left: Hannes Grobe, Wikimedia Commons, CC BY 3.0. Right: Tatsuo Yamashita, CC BY 2.0.
A Slate is a virtual layout surface – like a magic drawing tablet, you sketch content on it without it appearing on the page, inspect the result, and then place it wherever you want. A slate has its own grid and cursor, independent of the page.
Creating and placing a slate
<Slate name="sidebar">
<Grid width="5mm" height="12pt"/>
<Contents>
<PlaceObject>
<TextBlock>
<Paragraph><Value>Sidebar content</Value></Paragraph>
</TextBlock>
</PlaceObject>
</Contents>
</Slate>
<!-- Place the slate on the page -->
<PlaceObject slate="sidebar"/>Why use slates?
- Independent grid: A slate can use a finer or coarser grid than the page.
- Measure before placing: Use
sd:slate-width('name')andsd:slate-height('name')to query a slate’s dimensions before deciding where to put it. - Reuse: Place the same slate multiple times.
- Discard: If the content doesn’t fit or isn’t needed, simply don’t place it – nothing ends up in the PDF.
Querying slate dimensions
<Slate name="card">
<Contents>
<!-- build the card content -->
</Contents>
</Slate>
<!-- Check if it fits -->
<Switch>
<Case test="sd:slate-height('card', 'cm') < 5">
<PlaceObject slate="card"/>
</Case>
<Otherwise>
<ClearPage/>
<PlaceObject slate="card"/>
</Otherwise>
</Switch>