Value Objects API
TCPDF-Next usa value object immutabili per type safety e prevedibilità.
Color
Rappresenta colori in vari spazi colore:
php
use Yeeefang\TcpdfNext\Color\Color;
// RGB
$red = Color::rgb(255, 0, 0);
$blue = Color::rgb(0, 128, 255);
// Hex
$purple = Color::hex('#800080');
$cyan = Color::hex('#00FFFF');
// CMYK
$black = Color::cmyk(0, 0, 0, 100);
$magenta = Color::cmyk(0, 100, 0, 0);
// Grayscale
$gray = Color::gray(128);PageFormat
Dimensioni pagina standard ISO:
php
use Yeeefang\TcpdfNext\Document\PageFormat;
PageFormat::A4 // 210 x 297 mm
PageFormat::A3 // 297 x 420 mm
PageFormat::A5 // 148 x 210 mm
PageFormat::LETTER // 8.5 x 11 inch
PageFormat::LEGAL // 8.5 x 14 inch
// Personalizzato
$custom = PageFormat::custom(width: 200, height: 300); // mmOrientation
php
use Yeeefang\TcpdfNext\Document\Orientation;
Orientation::PORTRAIT
Orientation::LANDSCAPEMargins
php
use Yeeefang\TcpdfNext\Document\Margins;
// Uniform
$margins = Margins::uniform(15); // 15mm tutti i lati
// Asimmetrici
$margins = new Margins(
top: 20,
right: 15,
bottom: 20,
left: 15
);Point
Coordinate 2D:
php
use Yeeefang\TcpdfNext\Geometry\Point;
$point = new Point(x: 50.0, y: 100.0);
echo $point->x; // 50.0
echo $point->y; // 100.0Rectangle
Area rettangolare:
php
use Yeeefang\TcpdfNext\Geometry\Rectangle;
$rect = new Rectangle(
x: 10,
y: 20,
width: 100,
height: 50
);
echo $rect->area(); // 5000
echo $rect->perimeter(); // 300Tutti i value object sono immutabili — ogni modifica restituisce nuova istanza.