Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
LinkAnnotation
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
2 / 2
7
100.00% covered (success)
100.00%
1 / 1
 getSubtype
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toPdf
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
1 / 1
6
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Annotation;
6
7use Phpdftk\Pdf\Core\PdfArray;
8use Phpdftk\Pdf\Core\PdfDictionary;
9use Phpdftk\Pdf\Core\PdfName;
10use Phpdftk\Pdf\Core\Serializable;
11
12/**
13 * Link annotation (/Subtype /Link).
14 */
15class LinkAnnotation extends Annotation
16{
17    /**
18     * /Dest — destination for this link. Accepts PdfReference (for
19     * named-tree references), Destination (inline explicit destination
20     * — ISO 32000-2 Table 148), PdfArray (raw inline destination), or
21     * PdfString (legacy named destination).
22     */
23    public ?Serializable $dest = null;      // /Dest
24    public ?PdfDictionary $a = null;        // /A - action
25    public ?PdfDictionary $pa = null;       // /PA
26    public ?PdfArray $quadPoints = null;    // /QuadPoints
27    public ?PdfName $h = null;              // /H - highlight mode
28
29    public function getSubtype(): string
30    {
31        return 'Link';
32    }
33
34    public function toPdf(): string
35    {
36        $dict = $this->buildDictionary();
37
38        if ($this->dest !== null) {
39            $dict->set('Dest', $this->dest);
40        }
41        if ($this->a !== null) {
42            $dict->set('A', $this->a);
43        }
44        if ($this->pa !== null) {
45            $dict->set('PA', $this->pa);
46        }
47        if ($this->quadPoints !== null) {
48            $dict->set('QuadPoints', $this->quadPoints);
49        }
50        if ($this->h !== null) {
51            $dict->set('H', $this->h);
52        }
53
54        return $dict->toPdf();
55    }
56}