Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| OCConfig | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
12 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
24 / 24 |
|
100.00% |
1 / 1 |
12 | |||
| 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\PdfBoolean; |
| 9 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 10 | use Phpdftk\Pdf\Core\PdfName; |
| 11 | use Phpdftk\Pdf\Core\PdfObject; |
| 12 | use Phpdftk\Pdf\Core\PdfString; |
| 13 | use Phpdftk\Pdf\Core\PdfVersion; |
| 14 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 15 | |
| 16 | /** |
| 17 | * Optional content configuration dictionary — ISO 32000-2 §8.11.4.3, |
| 18 | * Table 101. |
| 19 | * |
| 20 | * Lives inside `OCPropertiesDict::$d` (default) or in the `/Configs` |
| 21 | * array (alternative configurations). Carries the initial on/off state |
| 22 | * of each OCG, the display tree order (/Order), radio-button groups |
| 23 | * (/RBGroups), and permanently locked groups (/Locked). |
| 24 | */ |
| 25 | #[RequiresPdfVersion(PdfVersion::V1_5)] |
| 26 | class OCConfig extends PdfObject |
| 27 | { |
| 28 | public ?PdfString $name = null; // /Name |
| 29 | public ?PdfString $creator = null; // /Creator |
| 30 | public ?PdfName $baseState = null; // /BaseState - ON | OFF | Unchanged |
| 31 | public ?PdfArray $on = null; // /ON |
| 32 | public ?PdfArray $off = null; // /OFF |
| 33 | public ?PdfArray $intent = null; // /Intent |
| 34 | public ?PdfArray $as = null; // /AS - auto-state |
| 35 | public ?PdfArray $order = null; // /Order |
| 36 | public ?PdfName $listMode = null; // /ListMode |
| 37 | public ?PdfArray $rbGroups = null; // /RBGroups |
| 38 | public ?PdfArray $locked = null; // /Locked |
| 39 | |
| 40 | public function toPdf(): string |
| 41 | { |
| 42 | $dict = new PdfDictionary(); |
| 43 | if ($this->name !== null) { |
| 44 | $dict->set('Name', $this->name); |
| 45 | } |
| 46 | if ($this->creator !== null) { |
| 47 | $dict->set('Creator', $this->creator); |
| 48 | } |
| 49 | if ($this->baseState !== null) { |
| 50 | $dict->set('BaseState', $this->baseState); |
| 51 | } |
| 52 | if ($this->on !== null) { |
| 53 | $dict->set('ON', $this->on); |
| 54 | } |
| 55 | if ($this->off !== null) { |
| 56 | $dict->set('OFF', $this->off); |
| 57 | } |
| 58 | if ($this->intent !== null) { |
| 59 | $dict->set('Intent', $this->intent); |
| 60 | } |
| 61 | if ($this->as !== null) { |
| 62 | $dict->set('AS', $this->as); |
| 63 | } |
| 64 | if ($this->order !== null) { |
| 65 | $dict->set('Order', $this->order); |
| 66 | } |
| 67 | if ($this->listMode !== null) { |
| 68 | $dict->set('ListMode', $this->listMode); |
| 69 | } |
| 70 | if ($this->rbGroups !== null) { |
| 71 | $dict->set('RBGroups', $this->rbGroups); |
| 72 | } |
| 73 | if ($this->locked !== null) { |
| 74 | $dict->set('Locked', $this->locked); |
| 75 | } |
| 76 | return $dict->toPdf(); |
| 77 | } |
| 78 | } |