Repository navigation
Leave screen-only and unwritable hidden content out under PDFAauto and PDFXauto (#397) - #416
Merged
jakejackson1 merged 6 commits intoSep 23, 2026
Conversation
jakejackson1
force-pushed
the
feature/pdfa-2-conformance
branch
from
September 23, 2026 11:19
1bb1b2c to
5cfcc1d
Compare
…d 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>
… 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>
…am 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>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/397-pdfa-auto-visibility
branch
from
September 23, 2026 11:29
11ce795 to
d3c33ae
Compare
…ument under PDFAauto Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… fix/397-pdfa-auto-visibility
jakejackson1
added a commit
that referenced
this pull request
Sep 23, 2026
…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 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.
What changed
Some
visibilityvalues can't be written as optional content:printonlyandscreenonlyunder PDF/A-2 and PDF/A-3, and all three values under PDF/A-1b and PDF/X-1a.PDFAauto/PDFXauto: no change. These are refused with a PDF/A warning, andOutput()throws.printonlyis drawn normally. The archive or print file stands for the printed document.screenonlyis left out.hiddenis left out where optional content isn't allowed (PDF/A-1b, PDF/X-1a). Before this change it leaked as visible text. Under PDF/A-2 and PDF/A-3 it keeps its hidden optional content group, as before.The warning is still recorded in auto mode. That matches the existing visibility tests, and
Output()only reports warnings without auto.How content is left out
Content that is left out is still laid out, so it keeps its CSS
visibility: hiddenspace. WhereSetVisibility()would write/OC … BDCandEMC, it writes a pair of markers instead.PageWriterremoves everything between each pair when it writes the page. The markers go through the same column, keep-with-table and header buffers as the marked content they replace, andAddPage()andClose()already end and restart visibility at page boundaries. So this works the same for blocks, spans and content across page breaks.After a dropped region,
resumeAfterDroppedContent()clears thepageoutputcache and writes the font, line width, colours and spacing that are in force. Without this, a setter called inside the region would leave the cache claiming a state the stream no longer has.Nothing that is left out registers anything:
printobjectbuffer()skips objects that are left out, so they add no form field, annotation, bookmark, TOC or index entry, and no image link.Link()andIndexEntry()(which covers the tag-timexrefpath) return early.Span visibility now reaches objects inside the span. Objects buffered through
_saveTextBuffer()pick it up in the chunk loops. The four tags that push straight into the buffer (annotation, bookmark, indexentry, tocentry) stamp it themselves, throughTag::withSpanVisibility(). One side effect: an image inside a hidden span is now hidden in ordinary documents too, where before it showed.I went with markers rather than skipping at the tag level the way
display: nonedoes. Skipping at the tag level would lose the layout space.Verification
tests/Mpdf/AutoVisibilityTest.php:PdfaConformanceTest::testVisibilityConformsruns a document with all three values, as blocks and spans with a link and an annotation, at 1-B, 2-B and 2-U. veraPDF passes all three.txtwriteon 1-B, 2-B and X-1a auto output shows the print-only text and none of the screen-only or hidden text.composer test(3401 tests),--group=snapshot(85 tests, no fixture changes),--group=conformance(19 tests),composer csand PHPStan are all clean.Fixes #397
🤖 Generated with Claude Code