Repository navigation
Write PDF/A-2b and PDF/A-2u documents that keep their transparency - #330
Merged
Merged
Conversation
This was referenced Sep 22, 2026
jakejackson1
force-pushed
the
feature/pdfa-2-conformance
branch
from
September 23, 2026 01:30
8e388e9 to
c93b66a
Compare
Member
Author
|
Rebased onto How the overlaps were resolved:
Gates on c93b66a:
|
This was referenced Sep 23, 2026
PDFAversion now takes 2-B and 2-U (and 3-U), and refuses the parts and levels mPDF cannot produce instead of claiming them. Under PDF/A-2 and PDF/A-3 a document keeps what PDF/A-1 forbids: opacity, rgba()/cmyka() colours, gradient and PNG alpha as soft masks, watermarks and page transparency groups. What PDF/A-2 asks in return: - annotations carry an appearance stream - an annotation embeds a file only if it is a PDF/A document - every glyph maps to Unicode: the ToUnicode CMap's single <0000> <FFFF> range mapped nothing past <00FF>, so each row of 256 codes now gets a range of its own (fixture refresh) - SVG form objects name the resource dictionary their graphics states are in (fixture refresh) Also fixes PDFAauto drawing an rgba() colour as CMYK in an RGB document, and the /Annots list pointing at the wrong objects when an annotation's file was not allowed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The workflow installs a pinned veraPDF (cached per version) and runs the conformance test group, failing on a skip so a broken install cannot pass quietly. The VeraPdf test trait checks a document against any flavour veraPDF knows, so PDF/UA and further PDF/A tests join the same group. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PDF/A-2b is the level archives and validators most often expect, so a document that sets PDFA without a PDFAversion now gets it rather than PDF/A-1b, and keeps its transparency. The config describes when to pick each supported version. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Bundles the SWOP2006_Coated3v2 CMYK profile (IDEAlliance, freely redistributable unmodified; see data/iccprofiles/NOTICE.md) so the tests can write a CMYK output intent. Its box shadow exposed CMYK patch meshes turning 100% into 254 through a float to int conversion PHP 8.1 deprecates; they now round. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The patch mesh opacity bytes truncated 100% to 254 as its colour bytes did; one helper now rounds both, and the shadow fixture's blurred edges come out fully opaque where they should. The conformance tests ask whether veraPDF runs once, and skip before building documents where it does not. Their helpers, and those of the PDF/A-2 and ToUnicode tests, build on PageStreams and pdfaConformance() instead of repeating them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
/Subj was left out under any PDF/A or PDF/X setting because it is a PDF 1.5 key. PDF/A-2 and PDF/A-3 are based on PDF 1.7, so it is now left out only under PDF/X-1a and PDF/A-1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
PDF/A-2 and PDF/A-3 allow optional content when every configuration dictionary has a /Name, none has /AS, and /Order lists every group. Mpdf::optionalContentAllowed() gates layers and visibility on the same parts as transparency; the default configuration now carries a /Name, and /AS is left out of PDF/A documents. Print-only and screen-only content is still refused under PDF/A, since it is switched by /AS alone. PDF/A-1 and PDF/X now refuse layers and visibility before registering them, so no optional content leaks into the catalog as it did before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…hem in PageWriter MetadataWriter::numberAnnotations() numbers every link, annotation (with its popup or embedded file and PDF/A appearance), form widget and radio group in the order writeAnnotations() writes them. writeAnnotations() then writes each object under its number and refers to the others by number, not by offset from the one it is writing. PageWriter writes /Annots from the numbers it is handed. The output is byte-identical. Fixes #352 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…, 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>
… veraPDF (#347) Under PDF/A-3 the file of an <annotation file="..."> now goes through the same writer as SetAssociatedFiles(): an indirect file specification with /AFRelationship /Unspecified, named by the annotation's own /AF, and an embedded file stream with a MIME /Subtype of application/octet-stream. numberAnnotations() gives the file specification its own object number, ahead of the stream's. PDF/A-1, PDF/A-2 and non-PDF/A output are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…e whole path A file annotation's name kept everything after the last forward slash, so on Windows the drive and directories stayed in the name (D:\a\x.php became Dax.php). Strip up to the last slash or backslash. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…to redraw only text it cannot shape (#348, #59) (#387) * Draw every active form widget in a PDF/A document instead of asking the viewer to (#348) Checkboxes and radio buttons switched to ZapfDingbats, which mPDF cannot embed, so PDF/A and PDF/X threw. They now draw the shapes mPDF already has for formUseZapD = false, in the colour space the output intent allows. Under PDF/A, text fields, choices and push buttons get an appearance stream laid out when the widget is placed (value, password mask, wrapped textarea, selected option, list box highlight, caption or icon), the AcroForm drops /NeedAppearances, hidden inputs and noprint buttons are printed, and JavaScript, submit and reset actions are left out. Without PDFAauto the dropped actions and noprint are reported as PDF/A warnings. Other documents still ask the viewer to redraw widgets, and now name the ZaDb font it redraws checkboxes with in /DR, which stops poppler warning of an unknown font tag (#59). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Give every active text field, choice and push button its own appearance Viewers that ignore /NeedAppearances, as many mobile, print and preview ones do, drew these widgets empty. The appearances PDF/A needed are now written for every document, with core-font text in Windows-1252 and embedded-font text in UTF-16. Outside PDF/A the form still asks the viewer to redraw them, and keeps its actions and its hidden and noprint flags. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Ask the viewer to redraw form fields only for text their appearances cannot shape Every widget now carries an appearance, so /NeedAppearances is written only when a field's value, options or caption is in a right-to-left script or a script with a shaper of its own (Otl::hasComplexScript), which mPDF's appearances neither reorder nor shape (#408). PDF/A never writes it. /ZaDb joins /DR only alongside the flag, when there is a checkbox or radio button to redraw (#59). Without the flag, viewers draw checkboxes and radio buttons from their own appearances, and the ZapfDingbats ones have no bounding box and no off state to draw. Every document now uses the vector shapes PDF/A and PDF/X already drew, and the formUseZapD property that chose between them is gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Refresh the form snapshots for the appearances every widget now carries Ghostscript draws a widget from its appearance where it has one. In page-break-avoid-forms the select shows its selected option rather than its export value, the buttons show their captions, and the checkboxes and radio buttons are the vector shapes; in page-break-avoid-references only the text field is drawn differently. Neither document asks the viewer to redraw its widgets any more, so /NeedAppearances and /ZaDb are gone from both. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Keep the check box and radio paths on one source line, so a Windows checkout writes no CR The paths were string literals running over two lines. With text=auto, Git checks them out with CRLF on Windows, and the carriage return reached the appearance stream, so the page-break-avoid-forms snapshot differed there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Snapshot every form field, drawn statically, as active widgets and in PDF/A The same page of fields renders three ways: into the page without active forms (form-fields-static), as widgets with their own appearances (form-fields-active) and as a PDF/A-2b document drawn from the appearances alone (form-fields-pdfa). The page has text, password, read-only, disabled, required and maxlength inputs, short and wrapped text areas, a combo box, a list box and a multiple select, checkboxes and a radio group, submit, reset, script and image buttons, a hidden input, a field styled in CSS, and an Arabic value, which has the active document ask the viewer to redraw its widgets. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… a test means it gravitypdf now reads an annotation's file through the asset fetcher and embeds only the types annotationFileAllowList maps, and <annotation file=""> also needs allowHtmlAnnotationFiles. The annotation tests attached a .php file from HTML, so they now attach tests/data/annotation-files/sample.txt with allowHtmlAnnotationFiles on. A PDF/A-3 file is written with the MIME type detected for it. PDF/A documents now default to PDF/A-2b, so the SVG alpha, header version and cross-reference tests that mean PDF/A-1b say so. The form field fixtures are refreshed for selects written as combo boxes and disabled text greyed through the colour converter. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
feature/pdfa-2-conformance
branch
from
September 23, 2026 11:19
1bb1b2c to
5cfcc1d
Compare
… resolves it on Windows Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…d PDFXauto (#397) (#416) * Leave screen-only and unwritable hidden content out under PDFAauto and PDFXauto (#397) PDF/A-2 forbids the /AS entry that print-only and screen-only content depend on, and PDF/A-1b and PDF/X-1a forbid optional content altogether. Without auto these are still refused with a warning, so Output() throws. Under auto, print-only content is now drawn, because the archive stands for the printed document. Screen-only content is left out, and so is hidden content where optional content is not allowed. Under PDF/A-2 and PDF/A-3, hidden content stays in its hidden group. Content that is left out is still laid out, so it keeps its space. It is written between markers where the optional content operators would go, and PageWriter removes it together with the markers. The font, colours and line width in force are then written again. Its backgrounds are skipped. Its objects register no link, form field, annotation, bookmark or index entry. An object inside a span now carries the span's visibility. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Look up a visibility group with array_key_exists(), which PHP 5.6 can parse PHP 5.6 cannot apply isset() to an element of a class constant array. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Leave out an image title in left-out content, and share the page stream parser An image's title annotation now takes the visibility of its span, like the other objects a tag puts straight into the text buffer. The visibility groups reuse OptionalContentWriter's table rather than repeat its bits, the per-object drop check no longer re-tests the block's visibility each time, and IndexEntry() drops a guard the object buffer already covers. The page content parser moves into PageStreams as pageContents(). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Say what the left-out content comments mean in fewer words Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Snapshot print-only, screen-only and hidden content in a PDF/A-1b document under PDFAauto Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 23, 2026
Merged
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.
Summary
PDFAversionnow accepts2-Band2-U(plus3-U), and the default is2-B. Documents at every level mPDF writes pass veraPDF (1-B, 2-B, 2-U, 3-B, 3-U), in RGB and with a CMYK output intent. A new Conformance workflow checks this on every PR.PDF/A-2 keeps what PDF/A-1 forbids.
Mpdf::transparencyAllowed()replaces thePDFA || PDFXchecks wherever they were about transparency. Under PDF/A-2 and PDF/A-3 the document keeps:rgba()/cmyka()alpha, which also covers gradients, shadows and SVG coloursMpdf::optionalContentAllowed()gates them. The default configuration gets a/Name, and/ASis left out. Print-only and screen-only content is still refused, since only/ASswitches it./Subj(Annotations drop /Subj under PDF/A-2 and PDF/A-3, which are based on PDF 1.7 #350), which is only a PDF 1.5 keyWhat PDF/A-2 and PDF/A-3 require in return:
annotationFileAllowList. On top of that, PDF/A-1 embeds none, and PDF/A-2 embeds a file only if it is a PDF/A document, judged by its uncompressedpdfaid:partclaim (6.8). The claim is read from the contents the asset fetcher loaded. A file left out is reported inPDFAXwarningsunlessPDFAautois set. Under PDF/A-3 the file is written as an associated file (A file attachment on an annotation fails PDF/A-3: no MIME subtype, AFRelationship or /AF association #347): a file specification with/AFRelationship /Unspecified, named by the annotation's/AF, and a stream carrying the MIME type detected for the file./NeedAppearancesstill draw them. Checkboxes and radio buttons always use the vector shapes, so theformUseZapDproperty is gone./NeedAppearancesis written only when a field holds text the appearances can't shape (RTL or complex scripts), and never under PDF/A./ZaDbjoins/DRonly alongside that flag, which stops Poppler's "Unknown font tag ZaDb" warning (Poppler warns 'Unknown font tag ZaDb' for every active checkbox and radio button #59). Under PDF/A, JavaScript, submit and reset actions are left out, and hidden and noprint widgets are printed. WithoutPDFAauto, each of these is reported as a warning.PDF/A-1b now conforms too (#346):
allowedAlpha()./Cunder a CMYK output intent.Annotation object numbers (#352).
MetadataWriter::numberAnnotations()numbers every link, annotation (with its popup or file, and its PDF/A appearance), form widget and radio group once, in the orderwriteAnnotations()writes them.PageWriterbuilds/Annotsfrom those numbers instead of predicting offsets.The default is now
2-B(was1-B). A document that setsPDFA => truewithout aPDFAversionnow gets PDF/A-2b. It keeps its transparency and allows watermarks, and its catalog declares PDF 1.7. To keep the old output, setPDFAversion => '1-B'. The config now describes when to use each version.Version validation.
PDFAversionvalues mPDF can't produce now throw rather than being written into the metadata:1-A,2-A,3-A,1-U.Bugs fixed along the way:
PDFAauto, anrgba()colour was converted to CMYK in an RGB document, andcmyka()was converted to RGB under PDF/X.convertImage()like other alpha PNGs, so it keeps its mask where transparency is allowed.D:\a\x.phpbecameDax.php).Rebased on
gravitypdfThe branch is rebased onto the current
gravitypdf, and the two merge commits from #358 and #361 are now linear. Where the two sides met:settleAnnotations()first runsgravitypdf'sloadAnnotationFiles(), now private. The PDF/A embed check reads the loaded contents instead of callingfile_get_contents()on the path. It does this beforenumberAnnotations()counts any objects.setMinPdfVersion()(The PDF header keeps the version it was written with, however pdf_version is raised later #339).tests/data/annotation-files/sample.txtwithallowHtmlAnnotationFiles, instead of a.phpfile the allow list rejects.PDFAversion => '1-B'.form-fields-*andpage-break-avoid-formsfixtures are refreshed for selects written as combo boxes (Write a select without a size as a combo box (#396) #419).Tests
PDFA2Test,PDFA1Test,PdfaOptionalContentTest,AnnotationObjectNumbersTest,FormAppearanceTest,ColorSpaceRestrictorTest,FontSubsetterCmapTest,CmykPatchMeshTest, and new version cases inPDFATest.PdfaConformanceTestruns veraPDF on 1-B, 2-B, 2-U, 3-B and 3-U, each with the default sRGB output intent and with a CMYK one. It also covers attachments, layers and active forms. It is in theconformancegroup and uses a newVeraPdftest trait, which takes any veraPDF flavour (2b,ua1, …).conformance.yml: installs a pinned veraPDF (VERAPDF_VERSION, cached per version) and runs--group=conformance --fail-on-skipped, so a broken install fails instead of skipping. The main matrix has no veraPDF and skips these tests.data/iccprofiles/SWOP2006_Coated3v2.icc(2.7 MB), with aNOTICE.mdfor its licence. IDEAlliance allows redistribution unmodified. Nothing embeds it unlessICCProfilepoints at it.form-fields-static,form-fields-activeandform-fields-pdfa.page-break-avoid-formsandpage-break-avoid-references(widget appearances),shadow(fully opaque blurred edges, RMSE 0.0002), andimage-border-radiusandsvg-class, whose SVG form XObjects now name/Resources 2 0 Rfor their graphics states (6.2.2).composer cs, PHPStan and a PHP 5.6 lint of the changed files.Fixes #346. Fixes #347. Fixes #348. Fixes #350. Fixes #351. Fixes #352. Fixes #59.
🤖 Generated with Claude Code