Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
MarkInfo
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
4
100.00% covered (success)
100.00%
1 / 1
 toPdf
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
4
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Core\Document;
6
7use Phpdftk\Pdf\Core\PdfBoolean;
8use Phpdftk\Pdf\Core\PdfDictionary;
9use Phpdftk\Pdf\Core\PdfVersion;
10use Phpdftk\Pdf\Core\RequiresPdfVersion;
11use Phpdftk\Pdf\Core\Serializable;
12
13/**
14 * PDF MarkInfo dictionary.
15 *
16 * Indicates whether and how the document is structured for accessibility.
17 * Assigned to /MarkInfo in the document Catalog.
18 *
19 * Example:
20 *   $markInfo = new MarkInfo();
21 *   $markInfo->marked = true;
22 *   $catalog->markInfo = $markInfo;
23 */
24class MarkInfo implements Serializable
25{
26    public ?bool $marked = null;          // /Marked - document contains marked content
27    #[RequiresPdfVersion(PdfVersion::V1_6)]
28    public ?bool $userProperties = null;  // /UserProperties - user properties attached to marked content (PDF 1.6+)
29    #[RequiresPdfVersion(PdfVersion::V1_6)]
30    public ?bool $suspects = null;        // /Suspects - structure may contain suspects (PDF 1.6+)
31
32    public function toPdf(): string
33    {
34        $dict = new PdfDictionary();
35
36        if ($this->marked !== null) {
37            $dict->set('Marked', new PdfBoolean($this->marked));
38        }
39        if ($this->userProperties !== null) {
40            $dict->set('UserProperties', new PdfBoolean($this->userProperties));
41        }
42        if ($this->suspects !== null) {
43            $dict->set('Suspects', new PdfBoolean($this->suspects));
44        }
45
46        return $dict->toPdf();
47    }
48}