Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| BoxStyle | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
5 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfArray; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfNumber; |
| 11 | use Phpdftk\Pdf\Core\PdfVersion; |
| 12 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 13 | use Phpdftk\Pdf\Core\Serializable; |
| 14 | |
| 15 | /** |
| 16 | * Box-style dictionary — ISO 32000-2 §14.11.2.3, Table 337. |
| 17 | * |
| 18 | * Describes how a page crop/bleed/trim/art box guide is drawn in print |
| 19 | * preview. Carried inline inside a {@see BoxColorInfo} entry. |
| 20 | */ |
| 21 | #[RequiresPdfVersion(PdfVersion::V1_3)] |
| 22 | class BoxStyle implements Serializable |
| 23 | { |
| 24 | public ?PdfArray $c = null; // /C - 3-element RGB color |
| 25 | public ?float $w = null; // /W - line width (default 1) |
| 26 | public ?PdfName $s = null; // /S - style: S, D (dashed) |
| 27 | public ?PdfArray $d = null; // /D - dash pattern |
| 28 | |
| 29 | public function toPdf(): string |
| 30 | { |
| 31 | $dict = new PdfDictionary(); |
| 32 | if ($this->c !== null) { |
| 33 | $dict->set('C', $this->c); |
| 34 | } |
| 35 | if ($this->w !== null) { |
| 36 | $dict->set('W', new PdfNumber($this->w)); |
| 37 | } |
| 38 | if ($this->s !== null) { |
| 39 | $dict->set('S', $this->s); |
| 40 | } |
| 41 | if ($this->d !== null) { |
| 42 | $dict->set('D', $this->d); |
| 43 | } |
| 44 | return $dict->toPdf(); |
| 45 | } |
| 46 | } |