Skip to content

Add support for field hierarchies - #5097

Merged
JorjMcKie merged 1 commit into
mainfrom
support-field-hierarchy
Aug 24, 2026
Merged

JorjMcKie merged 1 commit into
mainfrom
support-field-hierarchy

Conversation

@JorjMcKie

Copy link
Copy Markdown
Collaborator

This fix adds Form Field hierarchy support to our Widget handling.
Background:

PyMuPDF (like MuPDF itself) always inserts new Form Fields as widgets on the respective page. All inserted widgets automatically become root fields in the PDF.
There is no way to add complex information structures like Person.Name.First such that the widget only has the name part First and the other segments are parents in multiple hierarchy levels.

This fix solves this by automatically adding the hierarchy where needed. For the example above, a chain Person → Name → First will be created. Person becomes a root field pointing to Name via its /Kids array, and similarly Name points to First. Name and First in turn will point backwards to their parents via the /Parent key. This allows for tree-like information structures like this:

Person
  ↪ Name
     ↪ First
     ↪ Last
  ↪ Address
     ↪ Street
     ↪ City

The only root field would be Person. The four level 3 items would represent widgets living on any pages.
This behavior is triggered by the presence of the name segmentation indicator colon ".".
If no colon is present, the old behavior occurs.

@JorjMcKie
JorjMcKie force-pushed the support-field-hierarchy branch 6 times, most recently from c6f1a82 to adced32 Compare August 21, 2026 16:40
@julian-smith-artifex-com

Copy link
Copy Markdown
Collaborator

[mupdf master and 1.28.x have just been updated with the fix for swig-4.5. We need to rerun test_quick after these changes have made it to the github mupdf mirror, so rerun in an hour or so.]

Comment thread tests/test_widgets.py Outdated
@JorjMcKie
JorjMcKie merged commit 561a51d into main Aug 24, 2026
3 checks passed
@JorjMcKie
JorjMcKie deleted the support-field-hierarchy branch August 24, 2026 13:55
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants