Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
PdfRFontConstraint
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 check
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Conformance\Constraint;
6
7use Phpdftk\Pdf\Conformance\Inspection\DocumentInspector;
8use Phpdftk\Pdf\Conformance\Profile\ConformanceProfile;
9use Phpdftk\Pdf\Conformance\Result\ConformanceViolation;
10use Phpdftk\Pdf\Conformance\Result\ViolationSeverity;
11
12/**
13 * ISO 23504-1 (PDF/R-1): Font presence warning.
14 *
15 * PDF/R-1 documents are intended for raster-only content. The presence
16 * of fonts suggests non-raster content, which is a conformance warning.
17 */
18final class PdfRFontConstraint implements ConformanceConstraint
19{
20    public function check(DocumentInspector $inspector, ConformanceProfile $profile): array
21    {
22        foreach ($inspector->getFonts() as $_) {
23            return [
24                new ConformanceViolation(
25                    clause: '6.3',
26                    message: 'PDF/R-1 documents should not contain fonts; raster-only content expected',
27                    severity: ViolationSeverity::Warning,
28                    objectPath: 'Document.Fonts',
29                ),
30            ];
31        }
32
33        return [];
34    }
35}