ListRenderer
in package
Renders {@see ListBlock} content into a {@see ContentStream}.
The renderer is stateless; pagination logic lives at the call site
(Pdf::addList measures each item and starts a new page when one
would overflow). Items are independent — measure and draw one at a
time, threading a running item number for numbered lists.
Coordinates: $y is the top of the area available to the item; the
renderer draws downward and returns the height consumed.
Table of Contents
Methods
- drawBlock() : float
- Convenience: draw an entire {@see ListBlock} starting at `(x, y)` without pagination. Returns the height consumed. Useful for `Writer\Page::drawList()` — for flow-paginated rendering, drive the per-item loop yourself via {@see measureItem}/{@see drawItem}.
- drawItem() : float
- Draw a single item at `(x, y)`. The marker (bullet glyph or numbered prefix) sits at `$x`; the wrapped text starts at `$x + $style->indent`.
- measureItem() : float
- Height needed to render a single item, in points.
Methods
drawBlock()
Convenience: draw an entire {@see ListBlock} starting at `(x, y)` without pagination. Returns the height consumed. Useful for `Writer\Page::drawList()` — for flow-paginated rendering, drive the per-item loop yourself via {@see measureItem}/{@see drawItem}.
public
drawBlock(ContentStream $cs, float $x, float $y, ListBlock $block, float $maxWidth, Font $font, AfmData $metrics, float $fontSize, float $lineHeight, ListStyle $style) : float
Parameters
- $cs : ContentStream
- $x : float
- $y : float
- $block : ListBlock
- $maxWidth : float
- $font : Font
- $metrics : AfmData
- $fontSize : float
- $lineHeight : float
- $style : ListStyle
Return values
floatdrawItem()
Draw a single item at `(x, y)`. The marker (bullet glyph or numbered prefix) sits at `$x`; the wrapped text starts at `$x + $style->indent`.
public
drawItem(ContentStream $cs, float $x, float $y, string $item, float $maxWidth, Font $font, AfmData $metrics, float $fontSize, float $lineHeight, ListStyle $style, int|null $itemNumber) : float
Parameters
- $cs : ContentStream
- $x : float
- $y : float
- $item : string
- $maxWidth : float
- $font : Font
- $metrics : AfmData
- $fontSize : float
- $lineHeight : float
- $style : ListStyle
- $itemNumber : int|null
Return values
floatmeasureItem()
Height needed to render a single item, in points.
public
measureItem(string $item, float $maxWidth, Font $font, AfmData $metrics, float $fontSize, float $lineHeight, ListStyle $style) : float
Parameters
- $item : string
- $maxWidth : float
- $font : Font
- $metrics : AfmData
- $fontSize : float
- $lineHeight : float
- $style : ListStyle