Documentation

Layout
in package

Pdf HTML table layout class

Two-pass table rendering: measures natural column widths from cell content, distributes the available table width across columns, then lays out rows top to bottom with per-row page-break checks and header-row repeat on page break.

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
6.0.0

Table of Contents

Constants

MIN_ROW_HEIGHT  = 20
Minimum row height

Methods

render()  : void
Render a <table> node onto the document
calculateColumnWidths()  : array<string|int, mixed>
Calculate each column's width, distributing the table's available width
cellStyles()  : array<string|int, mixed>
Resolve one cell's styles from its own tag/attributes, inheriting the table's styles
cellText()  : string
Resolve a cell's trimmed, whitespace-collapsed text content
drawRow()  : void
Draw one row: each cell's box, then its wrapped text
measureRowHeight()  : float
Measure a row's height as the max wrapped height across its cells
resolveExplicitWidth()  : float|null
Resolve a CSS width value (px or %) against the table's available width
spanHeight()  : float
Sum the heights of every row a cell spans
spanWidth()  : float
Sum the widths of every column a cell spans
widthBeforeColumn()  : float
Sum the widths of every column before a given column index

Constants

MIN_ROW_HEIGHT

Minimum row height

protected mixed MIN_ROW_HEIGHT = 20

Methods

render()

Render a <table> node onto the document

public static render(Parser $parser, Child $tableNode, array<string|int, mixed> $styles, int $startX, int $tableWidth, float $startY) : void
Parameters
$parser : Parser
$tableNode : Child
$styles : array<string|int, mixed>
$startX : int
$tableWidth : int
$startY : float

calculateColumnWidths()

Calculate each column's width, distributing the table's available width

protected static calculateColumnWidths(Parser $parser, Grid $grid, int $tableWidth, array<string|int, mixed> $styles) : array<string|int, mixed>
Parameters
$parser : Parser
$grid : Grid
$tableWidth : int
$styles : array<string|int, mixed>
Return values
array<string|int, mixed>

cellStyles()

Resolve one cell's styles from its own tag/attributes, inheriting the table's styles

protected static cellStyles(Parser $parser, Cell $cell, array<string|int, mixed> $parentStyles) : array<string|int, mixed>
Parameters
$parser : Parser
$cell : Cell
$parentStyles : array<string|int, mixed>
Return values
array<string|int, mixed>

cellText()

Resolve a cell's trimmed, whitespace-collapsed text content

protected static cellText(Cell $cell) : string

Uses getTextContent(false) rather than pop-dom's ignoreWhiteSpace=true mode, which normalizes every '.' into '. ' (sentence-punctuation spacing) - correct for prose, but it mangles decimal numbers like "$19.99" into "$19. 99". Whitespace/newlines from HTML source formatting are collapsed here instead, without that side effect.

Parameters
$cell : Cell
Return values
string

drawRow()

Draw one row: each cell's box, then its wrapped text

protected static drawRow(Parser $parser, array<string|int, mixed> $cells, array<string|int, mixed> $columnWidths, array<string|int, mixed> $styles, int $startX, float $rowTopY, array<string|int, mixed> $rowHeights) : void
Parameters
$parser : Parser
$cells : array<string|int, mixed>
$columnWidths : array<string|int, mixed>
$styles : array<string|int, mixed>
$startX : int
$rowTopY : float
$rowHeights : array<string|int, mixed>

measureRowHeight()

Measure a row's height as the max wrapped height across its cells

protected static measureRowHeight(Parser $parser, array<string|int, mixed> $cells, array<string|int, mixed> $columnWidths, array<string|int, mixed> $styles) : float
Parameters
$parser : Parser
$cells : array<string|int, mixed>
$columnWidths : array<string|int, mixed>
$styles : array<string|int, mixed>
Return values
float

resolveExplicitWidth()

Resolve a CSS width value (px or %) against the table's available width

protected static resolveExplicitWidth(string $value, int $tableWidth) : float|null
Parameters
$value : string
$tableWidth : int
Return values
float|null

spanHeight()

Sum the heights of every row a cell spans

protected static spanHeight(array<string|int, mixed> $rowHeights, Cell $cell) : float
Parameters
$rowHeights : array<string|int, mixed>
$cell : Cell
Return values
float

spanWidth()

Sum the widths of every column a cell spans

protected static spanWidth(array<string|int, mixed> $columnWidths, Cell $cell) : float
Parameters
$columnWidths : array<string|int, mixed>
$cell : Cell
Return values
float

widthBeforeColumn()

Sum the widths of every column before a given column index

protected static widthBeforeColumn(array<string|int, mixed> $columnWidths, int $col) : float
Parameters
$columnWidths : array<string|int, mixed>
$col : int
Return values
float

        
On this page

Search results