Skip to content

Commit 6d23224

Browse files
src/__init__.py tests/:JM_choice_options(): fix #4114.
Use pdf_dict_get_inheritable() when looking for 'Opt' array. Also added test_4114() to check the fix.
1 parent 1f2a7bd commit 6d23224

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18933,7 +18933,7 @@ def JM_choice_options(annot):
1893318933
if n == 0:
1893418934
return # wrong widget type
1893518935

18936-
optarr = mupdf.pdf_dict_get( annot_obj, PDF_NAME('Opt'))
18936+
optarr = mupdf.pdf_dict_get_inheritable( annot_obj, PDF_NAME('Opt'))
1893718937
liste = []
1893818938

1893918939
for i in range( n):

tests/resources/test_4114.pdf

104 KB
Binary file not shown.

tests/test_widgets.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,21 @@ def test_4965():
447447
print(f' {name=}')
448448
print(f' {value=}')
449449
print(f' {f_type=}')
450+
451+
452+
def test_4114():
453+
print()
454+
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4114.pdf')
455+
path_out = os.path.normpath(f'{__file__}/../../tests/test_4114_out.pdf')
456+
expected_values = [' - Select One - ', ' ', 'Cincinnati, OH 45999', 'Memphis, TN 37501', 'Ogden, UT 84201', 'Philadelphia, PA 19255']
457+
expected_values2 = [expected_values, expected_values]
458+
values = list()
459+
with pymupdf.open(path) as document:
460+
for page_i, page in enumerate(document):
461+
for widget in page.widgets():
462+
if widget.field_type_string == 'ComboBox':
463+
print(f'test_4114(): {page_i=} {widget.choice_values=}')
464+
values.append(widget.choice_values)
465+
widget.update()
466+
document.save(path_out)
467+
assert values == expected_values2

0 commit comments

Comments
 (0)