Repository navigation
Keep a PDF/A-1b document to what PDF/A-1 allows of fonts, SVG opacity, shadow blur and annotation colours - #361
Merged
jakejackson1 merged 1 commit intoSep 23, 2026
Conversation
jakejackson1
force-pushed
the
fix/346-pdfa-1b-conformance
branch
from
September 23, 2026 00:58
bb37ae8 to
20a50c8
Compare
Member
Author
|
Rebased onto
|
jakejackson1
force-pushed
the
feature/pdfa-2-conformance
branch
from
September 23, 2026 01:30
8e388e9 to
c93b66a
Compare
…, shadow blur and annotation colours (#346) veraPDF rejected PDF/A-1b documents on five rules: - 6.3.5-3: a CID font subset now carries a CIDSet naming each CID its CIDToGIDMap maps, and .notdef. Written only under PDF/A-1. - 6.3.7-3: a font subset written as a symbolic TrueType font leaves out its format 6 (1,0) cmap subtable under PDF/A-1, keeping the (3,0) one. - 6.4-5/6.4-6: SVG opacity, fill-opacity and stroke-opacity go through Mpdf::allowedAlpha(), as SetAlpha() does, so they paint opaque where transparency is not allowed. - 6.4-1: a blurred box-shadow fades out through a soft mask, so without transparency it is drawn unblurred, with its edge at the blur's midpoint. - 6.5.3-3: an annotation carries no /C under PDF/A-1 with a CMYK output intent; its appearance still has the colour. PdfaConformanceTest now validates its documents at 1-B too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/346-pdfa-1b-conformance
branch
from
September 23, 2026 01:37
20a50c8 to
b465e51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacks on #330.
A document written with
'PDFAversion' => '1-B'now passesverapdf --flavour 1b, with an sRGB or a CMYK output intent. Each rule from #346:FontWriterwrites a/CIDSetstream for each subset CIDFontType2 under PDF/A-1. It sets a bit for every CID the subset's CIDToGIDMap maps, plus CID 0 (.notdef). veraPDF also checks that the set is complete (cidSetListsAllGlyphs): with one CID left out, the document failed 6.3.5-3 again. PDF/A-2 and PDF/A-3 do not require a CIDSet, so none is written there./TrueTypesubset whose cmap held a format 6 (1,0) subtable and a format 4 (3,0) one.FontSubsetter::makeSubsetSIP()takes a new optional$oneCmapSubtableargument that leaves out (1,0), as it already does when the format 6 table would overflow.FontWriterpasses it under PDF/A-1. Readers look up (3,0) first for a symbolic TrueType font (ISO 32000-1, 9.6.6.4). The BMP CID subsets were already accepted.Image\Svg's four directAddExtGState()calls now go through a privateopacityState()helper. It passes each alpha through a newMpdf::allowedAlpha(), which holds the check that used to sit inline inSetAlpha(): opaque when!transparencyAllowed(), with the same PDFAXwarning whenPDFAautois off. The ExtGState keys and their order are unchanged, so no other output changes.bluris set to 0 and the Coons patch mesh with its soft mask is never built. A blur fades from fully painted atspread - blur/2to nothing atspread + blur/2. With no blur, the edge falls atspread, the blur's midpoint, so the shadow covers the same area and has the same weight as the blurred one, only with a hard edge. The other options were worse: painting the fade opaque would stretch the shadow to its outer edge, and dropping the shadow would lose it entirely. The shadow's colour is already made opaque, like any other alpha under PDF/A-1. A PDFAXwarning is recorded whenPDFAautois off.MetadataWriter::writeAnnotations()leaves out/Cunder PDF/A-1 withrestrictColorSpace3 (the CMYK output intent). The appearance stream PDF/A requires still draws the annotation in its colour.Also added:
Mpdf::pdfaPart(), which returns the PDF/A part or null, and a privateMpdf::pdfaxWarning().transparencyAllowed()now usespdfaPart().Tests
PdfaConformanceTest(conformancegroup) now runs its document at1-Bwith both the RGB and the CMYK intent. The document now also has FreeSerif Devanagari and an inline SVG usingopacity,fill-opacityandstroke-opacity. The watermark is shown only where transparency is allowed, because PDF/A-1 refuses watermarks by design. Without thesrc/changes, both 1-B cases fail.tests/Mpdf/PDFA1Test.php, with 1-B and 2-B cases for each fix: SVG alphas, blurred shadow (no/SMaskor type 6 shading), the warnings whenPDFAautois off, annotation/Cby version and intent, a CIDSet exactly equal to the CIDToGIDMap's mapped CIDs, and one cmap subtable in the embedded symbolic TrueType font. Every 1-B case fails without its fix.FontSubsetterCmapTest::testMakeSubsetSipWritesOneSubtableWhenAskedtests the new subsetter argument directly.Gates
vendor/bin/phpunit --group=conformance --fail-on-skipped: OK (12 tests)composer test: OK (3239 tests; the 5 skips are the usual Unicode/HarfBuzz/ICU data ones). No snapshot changed.composer cs: cleanphpstan --memory-limit=2G: no errorsphp -lunder PHP 5.6 on every changed file: cleanNot done
Nothing from #346 is left.
Fixes #346
🤖 Generated with Claude Code