Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| TransitionDict | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
8 | |
100.00% |
1 / 1 |
| toPdf | |
100.00% |
17 / 17 |
|
100.00% |
1 / 1 |
8 | |||
| 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\PdfNumber; |
| 11 | use Phpdftk\Pdf\Core\Serializable; |
| 12 | use Phpdftk\Pdf\Core\PdfVersion; |
| 13 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 14 | |
| 15 | /** |
| 16 | * PDF Page Transition dictionary (/Type /Trans). |
| 17 | * |
| 18 | * Defines the visual transition effect when advancing to a page. |
| 19 | * Assigned to Page::$transition; also used as the document-level |
| 20 | * /Trans entry via PdfWriter::setTransition(). |
| 21 | * |
| 22 | * Style (/S) values: |
| 23 | * Split, Blinds, Box, Wipe, Dissolve, Glitter, R, |
| 24 | * Fly, Push, Cover, Uncover, Fade |
| 25 | * |
| 26 | * Example: |
| 27 | * $t = new TransitionDict(); |
| 28 | * $t->s = new PdfName('Dissolve'); |
| 29 | * $t->d = new PdfNumber(1.5); |
| 30 | * $page->transition = $t; |
| 31 | */ |
| 32 | #[RequiresPdfVersion(PdfVersion::V1_1)] |
| 33 | class TransitionDict implements Serializable |
| 34 | { |
| 35 | public ?PdfName $s = null; // /S - transition style |
| 36 | public ?PdfNumber $d = null; // /D - duration in seconds (default 1) |
| 37 | public ?PdfName $dm = null; // /Dm - dimension: H (horizontal) or V (vertical) |
| 38 | public ?PdfName $m = null; // /M - motion: I (inward) or O (outward) |
| 39 | public ?PdfNumber $di = null; // /Di - direction in degrees (0, 90, 180, 270, 315) |
| 40 | public ?PdfNumber $ss = null; // /SS - scale (Fly only) |
| 41 | public ?bool $b = null; // /B - opaque (Fly only) |
| 42 | |
| 43 | public function toPdf(): string |
| 44 | { |
| 45 | $dict = new PdfDictionary(); |
| 46 | $dict->set('Type', new PdfName('Trans')); |
| 47 | |
| 48 | if ($this->s !== null) { |
| 49 | $dict->set('S', $this->s); |
| 50 | } |
| 51 | if ($this->d !== null) { |
| 52 | $dict->set('D', $this->d); |
| 53 | } |
| 54 | if ($this->dm !== null) { |
| 55 | $dict->set('Dm', $this->dm); |
| 56 | } |
| 57 | if ($this->m !== null) { |
| 58 | $dict->set('M', $this->m); |
| 59 | } |
| 60 | if ($this->di !== null) { |
| 61 | $dict->set('Di', $this->di); |
| 62 | } |
| 63 | if ($this->ss !== null) { |
| 64 | $dict->set('SS', $this->ss); |
| 65 | } |
| 66 | if ($this->b !== null) { |
| 67 | $dict->set('B', new PdfBoolean($this->b)); |
| 68 | } |
| 69 | |
| 70 | return $dict->toPdf(); |
| 71 | } |
| 72 | } |