Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| GroupAttributes | |
100.00% |
11 / 11 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfBoolean; |
| 8 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 9 | use Phpdftk\Pdf\Core\PdfName; |
| 10 | use Phpdftk\Pdf\Core\PdfVersion; |
| 11 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 12 | use Phpdftk\Pdf\Core\Serializable; |
| 13 | |
| 14 | /** |
| 15 | * Transparency group attributes dictionary (ISO 32000-2). |
| 16 | * |
| 17 | * Implements Serializable for inline use within Page or FormXObject. |
| 18 | */ |
| 19 | #[RequiresPdfVersion(PdfVersion::V1_4)] |
| 20 | class GroupAttributes implements Serializable |
| 21 | { |
| 22 | public PdfName $s; // /S - subtype (always /Transparency for transparency groups) |
| 23 | public ?PdfName $cs = null; // /CS - color space name |
| 24 | public ?PdfBoolean $i = null; // /I - isolated |
| 25 | public ?PdfBoolean $k = null; // /K - knockout |
| 26 | |
| 27 | public function __construct(string $subtype = 'Transparency') |
| 28 | { |
| 29 | $this->s = new PdfName($subtype); |
| 30 | } |
| 31 | |
| 32 | public function toPdf(): string |
| 33 | { |
| 34 | $dict = new PdfDictionary(); |
| 35 | $dict->set('Type', new PdfName('Group')); |
| 36 | $dict->set('S', $this->s); |
| 37 | |
| 38 | if ($this->cs !== null) { |
| 39 | $dict->set('CS', $this->cs); |
| 40 | } |
| 41 | if ($this->i !== null) { |
| 42 | $dict->set('I', $this->i); |
| 43 | } |
| 44 | if ($this->k !== null) { |
| 45 | $dict->set('K', $this->k); |
| 46 | } |
| 47 | |
| 48 | return $dict->toPdf(); |
| 49 | } |
| 50 | } |