Tag an inline image or form field where it falls among its line's text (#406) - #509
Open
jakejackson1 wants to merge 1 commit into
Open
jakejackson1 wants to merge 1 commit into
jakejackson1 wants to merge 1 commit into
Conversation
Under PDF/UA an object in a line is drawn as its chunk is reached rather than after the line's text, with the text's marked content closed around it. Its Figure or Form is then read between the text before and after it instead of nested inside the text's MCID, and what it tags goes in the element its chunk is in, so an image in a link is the Link's content. 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.
Under PDF/UA, an image, barcode, list marker or form field in a line was tagged out of reading order. This fixes all three items in #406.
Cause.
finishFlowingBlock()andWriteFlowingBlock()drew a line's text chunk by chunk, then drew the line's objects afterwards in a second pass (printobjectbuffer()). That caused three problems:/Figure <</MCID n>> BDCsat inside the paragraph's MCID. A barcode's Figure and a list marker'sLbldid the same.Formelement is placed by how much content its parent had when the field was added. SoStart <input type="checkbox"> Checkread as "Start Check, checkbox".<a href>got a Figure beside the Link, not inside it. If text followed the link, the image's link annotation lost its Link too, and the document failed with the "wraps no accessible content" exception.Fix. Under PDF/UA, an object that marks its own content (image, barcode, text circle, a list marker with its
Lbl, input, textarea, select) is now drawn right after its own chunk, byprintLineObject():restoreFont()restores, otherwise the block's element) is pushed onto the structure stack while the object draws. Whatever the object tags therefore goes inside it, e.g. a Figure inside the Link around it.The per-chunk marking that was copied in both loops is now
markLineChunk().Decisions:
pdfua: its bytes differ and its pages are identical, and it was refreshed withcomposer snapshot:update pdfua.How this interacts with #496 (#404). #496 closes the block's marked content around a static form field inside
printobjectbuffer()and reopens it afterwards. This PR does not touch that code. On the in-line path, the marked content is already closed beforeprintobjectbuffer()runs, so #496's close does nothing and it does not reopen. #496'sFormvalue element then lands in the paragraph between the text around it. I test-merged this branch with #496, #402 and #405: there were no conflicts, and the Ua suite (veraPDF included) passes.<p>Start <label><input type="checkbox" checked> I agree</label> end</p>then readsP [MCID 0, Form (☒), MCID 2]. Whichever PR lands second rebases.Tests.
tests/Mpdf/Ua/InlineObjectReadingOrderTest.phpcovers:The tests assert each element's
/Korder and that no MCID-bearing marked content opens inside other marked content. That check isassertNoNestedMarkedContent(), now inPdfUaTestCase. All five tests fail without the fix. The full suite,composer cs, PHPStan and the veraPDF conformance tests pass locally.Fixes #406
🤖 Generated with Claude Code