Skip to content

Add tagged content support inside transparency group XObjects#337

Open
dcalvo wants to merge 1 commit into
LaurenzV:mainfrom
dcalvo:xobject-tagging
Open

Add tagged content support inside transparency group XObjects#337
dcalvo wants to merge 1 commit into
LaurenzV:mainfrom
dcalvo:xobject-tagging

Conversation

@dcalvo
Copy link
Copy Markdown
Contributor

@dcalvo dcalvo commented Feb 20, 2026

This one is pretty chunky, sorry for opening so many PRs at once 😅 This is the last of the changes we've been carrying in our fork, happy to iterate on any of them. We're holding back a custom XMP callback PR for now.

When Surface creates sub-builders for transparency groups (push_mask, push_opacity, push_isolated), the resulting Form XObjects don't carry /StructParents entries. Any start_tagged/end_tagged calls inside the group emit BMC/EMC markers into the XObject's content stream, but those MCIDs aren't connected back to the page's parent tree. Tagged content inside transparency groups is invisible to the structure tree.

As noted in #313, this makes it impossible to produce correct tagged output when content sits inside transparency groups.

The fix:

  • Sub-builders get a unique XObjectTagId and inherit the parent's page index
  • start_tagged in a sub-builder allocates MCIDs from the XObject's own counter
  • When the sub-builder finishes, the XObject is written with a /StructParents key
  • The parent tree maps the XObject's MCIDs back to the corresponding struct elements

Per ISO 32000-2 §14.7.4.4.2, Form XObjects created by push_opacity,
push_mask, and push_isolated now participate in the structure tree.
Each sub-builder gets its own MCID counter and XObjectTagId. Structure
elements reference XObject content via MCR dicts with /Stm pointing to
the XObject stream. XObjects with tagged content get /StructParents
entries in the parent tree.
@LaurenzV
Copy link
Copy Markdown
Owner

LaurenzV commented Mar 1, 2026

Sorry, I haven't had the head space for krilla PRs recently, will try to take a look once I have a bit more time for that. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants