phpdftk API Documentation

Theme
in package

FinalYes

Document-wide styling defaults for the high-level {@see Pdf} builder.

Holds the page margins, body-text defaults (font, size, color, line height, paragraph spacing) and per-level heading styles (H1–H6). Individual Pdf::addText() calls can override parts of the theme via TextStyle; headings inherit from the theme's heading map.

Themes are immutable. Use the with* helpers to derive a modified theme without mutating the original.

Table of Contents

Properties

$color  : array<string|int, mixed>
$family  : string
$fontSize  : float
$footerHeight  : float
$headerHeight  : float
$headings  : array<string|int, mixed>
$lineHeight  : float
$margin  : float
$paragraphSpacing  : float
$quoteBarColor  : array{float, float, float}
$quoteBarWidth  : float
$quoteIndent  : float

Methods

__construct()  : mixed
heading()  : array{size: float, bold: bool, spaceAbove: float, spaceBelow: float}
withColor()  : self
withFont()  : self
withMargin()  : self

Properties

$color read-only

public array<string|int, mixed> $color = [0.0, 0.0, 0.0]

$family read-only

public string $family = 'Helvetica'

$fontSize read-only

public float $fontSize = 11.0

$footerHeight read-only

public float $footerHeight = 0.0

$headerHeight read-only

public float $headerHeight = 0.0

$headings read-only

public array<string|int, mixed> $headings = [1 => ['size' => 24.0, 'bold' => true, 'spaceAbove' => 18.0, 'spaceBelow' => 10.0], 2 => ['size' => 20.0, 'bold' => true, 'spaceAbove' => 14.0, 'spaceBelow' => 8.0], 3 => ['size' => 16.0, 'bold' => true, 'spaceAbove' => 12.0, 'spaceBelow' => 6.0], 4 => ['size' => 14.0, 'bold' => true, 'spaceAbove' => 10.0, 'spaceBelow' => 5.0], 5 => ['size' => 12.0, 'bold' => true, 'spaceAbove' => 8.0, 'spaceBelow' => 4.0], 6 => ['size' => 11.0, 'bold' => true, 'spaceAbove' => 6.0, 'spaceBelow' => 3.0]]

$lineHeight read-only

public float $lineHeight = 1.2

$margin read-only

public float $margin = 72.0

$paragraphSpacing read-only

public float $paragraphSpacing = 6.0

$quoteBarColor read-only

public array{float, float, float} $quoteBarColor = [0.7, 0.7, 0.7]

$quoteBarWidth read-only

public float $quoteBarWidth = 2.0

$quoteIndent read-only

public float $quoteIndent = 18.0

Methods

__construct()

public __construct([float $margin = 72.0 ][, string $family = 'Helvetica' ][, float $fontSize = 11.0 ][, array{float, float, float} $color = [0.0, 0.0, 0.0] ][, float $lineHeight = 1.2 ][, float $paragraphSpacing = 6.0 ][, array<int, array{size: float, bold: bool, spaceAbove: float, spaceBelow: float}> $headings = [1 => ['size' => 24.0, 'bold' => true, 'spaceAbove' => 18.0, 'spaceBelow' => 10.0], 2 => ['size' => 20.0, 'bold' => true, 'spaceAbove' => 14.0, 'spaceBelow' => 8.0], 3 => ['size' => 16.0, 'bold' => true, 'spaceAbove' => 12.0, 'spaceBelow' => 6.0], 4 => ['size' => 14.0, 'bold' => true, 'spaceAbove' => 10.0, 'spaceBelow' => 5.0], 5 => ['size' => 12.0, 'bold' => true, 'spaceAbove' => 8.0, 'spaceBelow' => 4.0], 6 => ['size' => 11.0, 'bold' => true, 'spaceAbove' => 6.0, 'spaceBelow' => 3.0]] ][, float $headerHeight = 0.0 ][, float $footerHeight = 0.0 ][, float $quoteIndent = 18.0 ][, float $quoteBarWidth = 2.0 ][, array<string|int, mixed> $quoteBarColor = [0.7, 0.7, 0.7] ]) : mixed
Parameters
$margin : float = 72.0

uniform page margin (points)

$family : string = 'Helvetica'

body font family (Helvetica / Times / Courier)

$fontSize : float = 11.0

body size

$color : array{float, float, float} = [0.0, 0.0, 0.0]

body RGB (0–1)

$lineHeight : float = 1.2

multiplier of font size

$paragraphSpacing : float = 6.0

gap between paragraphs (points)

$headings : array<int, array{size: float, bold: bool, spaceAbove: float, spaceBelow: float}> = [1 => ['size' => 24.0, 'bold' => true, 'spaceAbove' => 18.0, 'spaceBelow' => 10.0], 2 => ['size' => 20.0, 'bold' => true, 'spaceAbove' => 14.0, 'spaceBelow' => 8.0], 3 => ['size' => 16.0, 'bold' => true, 'spaceAbove' => 12.0, 'spaceBelow' => 6.0], 4 => ['size' => 14.0, 'bold' => true, 'spaceAbove' => 10.0, 'spaceBelow' => 5.0], 5 => ['size' => 12.0, 'bold' => true, 'spaceAbove' => 8.0, 'spaceBelow' => 4.0], 6 => ['size' => 11.0, 'bold' => true, 'spaceAbove' => 6.0, 'spaceBelow' => 3.0]]

map from level (1..6) to heading style

$headerHeight : float = 0.0
$footerHeight : float = 0.0
$quoteIndent : float = 18.0
$quoteBarWidth : float = 2.0
$quoteBarColor : array<string|int, mixed> = [0.7, 0.7, 0.7]

heading()

public heading(int $level) : array{size: float, bold: bool, spaceAbove: float, spaceBelow: float}
Parameters
$level : int
Return values
array{size: float, bold: bool, spaceAbove: float, spaceBelow: float}

withColor()

public withColor(array{float, float, float} $color) : self
Parameters
$color : array{float, float, float}
Return values
self

withFont()

public withFont(string $family, float $size) : self
Parameters
$family : string
$size : float
Return values
self

withMargin()

public withMargin(float $margin) : self
Parameters
$margin : float
Return values
self

        
On this page

Search results