Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
84.62% covered (warning)
84.62%
11 / 13
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ThreeDAnnotation
84.62% covered (warning)
84.62%
11 / 13
50.00% covered (danger)
50.00%
1 / 2
7.18
0.00% covered (danger)
0.00%
0 / 1
 getSubtype
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
83.33% covered (warning)
83.33%
10 / 12
0.00% covered (danger)
0.00%
0 / 1
6.17
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Annotation;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfBoolean;
9use Phpdftk\Pdf\Core\PdfDictionary;
10use Phpdftk\Pdf\Core\PdfReference;
11use Phpdftk\Pdf\Core\PdfVersion;
12use Phpdftk\Pdf\Core\RequiresPdfVersion;
13
14/**
15 * 3D annotation (/Subtype /3D).
16 */
17#[RequiresPdfVersion(PdfVersion::V1_6)]
18class ThreeDAnnotation extends Annotation
19{
20    public ?PdfReference $dd = null;    // /3DD - 3D stream
21    public ?PdfDictionary $dv = null;   // /3DV - default view
22    public ?PdfDictionary $da = null;   // /3DA - activation dict
23    public ?bool $di = null;            // /3DI - interactive
24    public ?PdfArray $db = null;        // /3DB - 3D box
25
26    public function getSubtype(): string
27    {
28        return '3D';
29    }
30
31    public function toPdf(): string
32    {
33        $dict = $this->buildDictionary();
34
35        if ($this->dd !== null) {
36            $dict->set('3DD', $this->dd);
37        }
38        if ($this->dv !== null) {
39            $dict->set('3DV', $this->dv);
40        }
41        if ($this->da !== null) {
42            $dict->set('3DA', $this->da);
43        }
44        if ($this->di !== null) {
45            $dict->set('3DI', new PdfBoolean($this->di));
46        }
47        if ($this->db !== null) {
48            $dict->set('3DB', $this->db);
49        }
50
51        return $dict->toPdf();
52    }
53}