Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
18 / 21 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| OutputIntent | |
85.71% |
18 / 21 |
|
50.00% |
1 / 2 |
9.24 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| toPdf | |
84.21% |
16 / 19 |
|
0.00% |
0 / 1 |
8.25 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core\Document; |
| 6 | |
| 7 | use Phpdftk\Pdf\Core\PdfDictionary; |
| 8 | use Phpdftk\Pdf\Core\PdfName; |
| 9 | use Phpdftk\Pdf\Core\PdfObject; |
| 10 | use Phpdftk\Pdf\Core\PdfReference; |
| 11 | use Phpdftk\Pdf\Core\PdfString; |
| 12 | use Phpdftk\Pdf\Core\PdfVersion; |
| 13 | use Phpdftk\Pdf\Core\RequiresPdfVersion; |
| 14 | |
| 15 | /** |
| 16 | * PDF Output Intent dictionary (ISO 32000-2 Table 365). |
| 17 | * |
| 18 | * Describes the intended output conditions for a document, required |
| 19 | * for PDF/X compliance. |
| 20 | */ |
| 21 | #[RequiresPdfVersion(PdfVersion::V1_4)] |
| 22 | class OutputIntent extends PdfObject |
| 23 | { |
| 24 | public const PDF_TYPE = 'OutputIntent'; |
| 25 | |
| 26 | public PdfName $s; // /S - required subtype |
| 27 | public ?PdfString $outputCondition = null; // /OutputCondition |
| 28 | public PdfString $outputConditionIdentifier; // /OutputConditionIdentifier - required |
| 29 | public ?PdfString $registryName = null; // /RegistryName |
| 30 | public ?PdfString $info = null; // /Info |
| 31 | public ?PdfReference $destOutputProfile = null; // /DestOutputProfile - ICC profile stream |
| 32 | public ?PdfReference $destOutputProfileRef = null; // /DestOutputProfileRef - external ICC ref (PDF/A-3+) |
| 33 | public ?PdfDictionary $mixingHints = null; // /MixingHints |
| 34 | public ?PdfDictionary $spectralData = null; // /SpectralData |
| 35 | |
| 36 | public function __construct(string $subtype, string $outputConditionIdentifier) |
| 37 | { |
| 38 | $this->s = new PdfName($subtype); |
| 39 | $this->outputConditionIdentifier = new PdfString($outputConditionIdentifier); |
| 40 | } |
| 41 | |
| 42 | public function toPdf(): string |
| 43 | { |
| 44 | $dict = new PdfDictionary(); |
| 45 | $dict->set('Type', new PdfName(self::PDF_TYPE)); |
| 46 | $dict->set('S', $this->s); |
| 47 | $dict->set('OutputConditionIdentifier', $this->outputConditionIdentifier); |
| 48 | |
| 49 | if ($this->outputCondition !== null) { |
| 50 | $dict->set('OutputCondition', $this->outputCondition); |
| 51 | } |
| 52 | if ($this->registryName !== null) { |
| 53 | $dict->set('RegistryName', $this->registryName); |
| 54 | } |
| 55 | if ($this->info !== null) { |
| 56 | $dict->set('Info', $this->info); |
| 57 | } |
| 58 | if ($this->destOutputProfile !== null) { |
| 59 | $dict->set('DestOutputProfile', $this->destOutputProfile); |
| 60 | } |
| 61 | if ($this->destOutputProfileRef !== null) { |
| 62 | $dict->set('DestOutputProfileRef', $this->destOutputProfileRef); |
| 63 | } |
| 64 | if ($this->mixingHints !== null) { |
| 65 | $dict->set('MixingHints', $this->mixingHints); |
| 66 | } |
| 67 | if ($this->spectralData !== null) { |
| 68 | $dict->set('SpectralData', $this->spectralData); |
| 69 | } |
| 70 | |
| 71 | return $dict->toPdf(); |
| 72 | } |
| 73 | } |