phpdftk API Documentation

PathBuilder
in package

FinalYes

Fluent builder for custom PDF paths.

Used with Page::drawPath() to construct complex shapes without knowing content stream operators. Supports lines, cubic Bézier curves, quadratic curves (converted to cubic), arcs, and closure.

Usage: $page->drawPath(function(PathBuilder $p) { $p->moveTo(100, 100) ->lineTo(200, 150) ->curveTo(250, 200, 300, 100, 350, 150) ->close(); }, fill: RgbColor::fromHex('#FF0000'));

Table of Contents

Methods

arcTo()  : self
Circular arc from startAngle to endAngle (in degrees, counterclockwise).
close()  : self
curveTo()  : self
Cubic Bézier curve to (x3, y3) with control points (x1, y1) and (x2, y2).
lineTo()  : self
moveTo()  : self
quadCurveTo()  : self
Quadratic Bézier curve — converted to cubic internally.

Methods

arcTo()

Circular arc from startAngle to endAngle (in degrees, counterclockwise).

public arcTo(float $cx, float $cy, float $r, float $startAngle, float $endAngle) : self

Approximated with Bézier curves (one per 90-degree segment).

Parameters
$cx : float
$cy : float
$r : float
$startAngle : float
$endAngle : float
Return values
self

curveTo()

Cubic Bézier curve to (x3, y3) with control points (x1, y1) and (x2, y2).

public curveTo(float $x1, float $y1, float $x2, float $y2, float $x3, float $y3) : self
Parameters
$x1 : float
$y1 : float
$x2 : float
$y2 : float
$x3 : float
$y3 : float
Return values
self

lineTo()

public lineTo(float $x, float $y) : self
Parameters
$x : float
$y : float
Return values
self

moveTo()

public moveTo(float $x, float $y) : self
Parameters
$x : float
$y : float
Return values
self

quadCurveTo()

Quadratic Bézier curve — converted to cubic internally.

public quadCurveTo(float $cpx, float $cpy, float $x, float $y) : self

A quadratic curve with control point (cpx, cpy) and end point (x, y) is converted to a cubic curve using the standard 2/3 approximation.

Parameters
$cpx : float
$cpy : float
$x : float
$y : float
Return values
self

        
On this page

Search results