Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| PdfEColorSpaceConstraint | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
| check | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
3 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Conformance\Constraint; |
| 6 | |
| 7 | use Phpdftk\Pdf\Conformance\Inspection\DocumentInspector; |
| 8 | use Phpdftk\Pdf\Conformance\Profile\ConformanceProfile; |
| 9 | use Phpdftk\Pdf\Conformance\Result\ConformanceViolation; |
| 10 | use Phpdftk\Pdf\Conformance\Result\ViolationSeverity; |
| 11 | |
| 12 | /** |
| 13 | * ISO 24517-1 (PDF/E-1): Color space validation. |
| 14 | * |
| 15 | * Device-dependent color spaces (DeviceRGB, DeviceCMYK, DeviceGray) should |
| 16 | * be anchored by an OutputIntent with an ICC profile, or device-independent |
| 17 | * color spaces should be used instead. |
| 18 | */ |
| 19 | final class PdfEColorSpaceConstraint implements ConformanceConstraint |
| 20 | { |
| 21 | public function check(DocumentInspector $inspector, ConformanceProfile $profile): array |
| 22 | { |
| 23 | // If an OutputIntent with ICC profile exists, device colors are anchored |
| 24 | if ($inspector->hasOutputIntentWithIccProfile()) { |
| 25 | return []; |
| 26 | } |
| 27 | |
| 28 | // Check whether device-dependent color spaces are used without an OutputIntent |
| 29 | if (!$inspector->hasOutputIntents()) { |
| 30 | return [ |
| 31 | new ConformanceViolation( |
| 32 | clause: '6.2.2', |
| 33 | message: 'PDF/E-1 documents using device-dependent color spaces should include an OutputIntent with ICC profile', |
| 34 | severity: ViolationSeverity::Warning, |
| 35 | objectPath: 'Catalog.OutputIntents', |
| 36 | ), |
| 37 | ]; |
| 38 | } |
| 39 | |
| 40 | return []; |
| 41 | } |
| 42 | } |