MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / get_widgets_by_name

Function get_widgets_by_name

tests/test_widgets.py:342–354  ·  view source on GitHub ↗

Extracts and returns a dictionary of widgets indexed by their names.

(doc)

Source from the content-addressed store, hash-verified

340 import collections
341
342 def get_widgets_by_name(doc):
343 """
344 Extracts and returns a dictionary of widgets indexed by their names.
345 """
346 widgets_by_name = collections.defaultdict(list)
347 for page_num in range(len(doc)):
348 page = doc.load_page(page_num)
349 for field in page.widgets():
350 widgets_by_name[field.field_name].append({
351 "page_num": page_num,
352 "widget": field
353 })
354 return widgets_by_name
355
356 # Open document and get widgets
357 path = os.path.normpath(f'{__file__}/../../tests/resources/test_4004.pdf')

Callers 1

test_4004Function · 0.85

Calls 3

load_pageMethod · 0.80
widgetsMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…