Skip to content

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 into
feature/pdfa-2-conformancefrom
fix/346-pdfa-1b-conformance
Sep 23, 2026
Merged

jakejackson1 merged 1 commit into
feature/pdfa-2-conformancefrom
fix/346-pdfa-1b-conformance

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

Stacks on #330.

A document written with 'PDFAversion' => '1-B' now passes verapdf --flavour 1b, with an sRGB or a CMYK output intent. Each rule from #346:

Rule Fix
6.3.5-3 CIDSet FontWriter writes a /CIDSet stream 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.
6.3.7-3 cmap subtables The failing font was FreeSerif written through the SIP/SMP path, a simple symbolic /TrueType subset whose cmap held a format 6 (1,0) subtable and a format 4 (3,0) one. FontSubsetter::makeSubsetSIP() takes a new optional $oneCmapSubtable argument that leaves out (1,0), as it already does when the format 6 table would overflow. FontWriter passes 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.
6.4-5 / 6.4-6 SVG opacity Image\Svg's four direct AddExtGState() calls now go through a private opacityState() helper. It passes each alpha through a new Mpdf::allowedAlpha(), which holds the check that used to sit inline in SetAlpha(): opaque when !transparencyAllowed(), with the same PDFAXwarning when PDFAauto is off. The ExtGState keys and their order are unchanged, so no other output changes.
6.4-1 box-shadow soft mask Under PDF/A-1 (and PDF/X), a blurred box-shadow is drawn without its blur: blur is set to 0 and the Coons patch mesh with its soft mask is never built. A blur fades from fully painted at spread - blur/2 to nothing at spread + blur/2. With no blur, the edge falls at spread, 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 when PDFAauto is off.
6.5.3-3 annotation /C MetadataWriter::writeAnnotations() leaves out /C under PDF/A-1 with restrictColorSpace 3 (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 private Mpdf::pdfaxWarning(). transparencyAllowed() now uses pdfaPart().

Tests

  • PdfaConformanceTest (conformance group) now runs its document at 1-B with both the RGB and the CMYK intent. The document now also has FreeSerif Devanagari and an inline SVG using opacity, fill-opacity and stroke-opacity. The watermark is shown only where transparency is allowed, because PDF/A-1 refuses watermarks by design. Without the src/ changes, both 1-B cases fail.
  • New tests/Mpdf/PDFA1Test.php, with 1-B and 2-B cases for each fix: SVG alphas, blurred shadow (no /SMask or type 6 shading), the warnings when PDFAauto is off, annotation /C by 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::testMakeSubsetSipWritesOneSubtableWhenAsked tests 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: clean
  • phpstan --memory-limit=2G: no errors
  • php -l under PHP 5.6 on every changed file: clean

Not done

Nothing from #346 is left.

Fixes #346

🤖 Generated with Claude Code

@jakejackson1 jakejackson1 added the enhancement New feature or request label Sep 23, 2026
@jakejackson1
jakejackson1 force-pushed the fix/346-pdfa-1b-conformance branch from bb37ae8 to 20a50c8 Compare September 23, 2026 00:58
@jakejackson1

Copy link
Copy Markdown
Member Author

Rebased onto feature/pdfa-2-conformance after #357, #359 and #360 merged.

  • Conflict: only tests/Mpdf/PdfaConformanceTest.php, where Allow layers and hidden content under PDF/A-2 and PDF/A-3 #359's testLayersConform sat next to this PR's reworded documents() docblock. I kept both.
  • Small addition: the /Subj condition from Keep an annotation's subject under PDF/A-2 and PDF/A-3 (#350) #357 now uses this PR's Mpdf::pdfaPart() instead of reading pdfaConformance()[0] itself. Behaviour is unchanged.
  • Gates on the rebased commit:
    • full suite: 3265 tests, 5 skipped
    • --group=conformance --fail-on-skipped: 14 veraPDF cases, PDF/A-1b through 3-U, plus attachments and layers
    • composer cs and PHPStan: clean
    • PHP 5.6 lint of the two files touched in the rebase: clean

@jakejackson1
jakejackson1 force-pushed the feature/pdfa-2-conformance branch from 8e388e9 to c93b66a Compare September 23, 2026 01:30
…, 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
jakejackson1 force-pushed the fix/346-pdfa-1b-conformance branch from 20a50c8 to b465e51 Compare September 23, 2026 01:37
@jakejackson1
jakejackson1 merged commit fcd5924 into feature/pdfa-2-conformance Sep 23, 2026
29 checks passed
@jakejackson1
jakejackson1 deleted the fix/346-pdfa-1b-conformance branch September 30, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant