Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18933,7 +18933,7 @@ def JM_choice_options(annot):
if n == 0:
return # wrong widget type

optarr = mupdf.pdf_dict_get( annot_obj, PDF_NAME('Opt'))
optarr = mupdf.pdf_dict_get_inheritable( annot_obj, PDF_NAME('Opt'))
liste = []

for i in range( n):
Expand Down
Binary file added tests/resources/test_4114.pdf
Binary file not shown.
24 changes: 24 additions & 0 deletions tests/test_rewrite_images.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pymupdf
import os
import util


scriptdir = os.path.dirname(__file__)

Expand All @@ -13,3 +15,25 @@ def test_rewrite_images():
data = doc.tobytes(garbage=3, deflate=True)
size1 = len(data)
assert (1 - (size1 / size0)) > 0.3


def test_4918():
'''
By default this test does nothing, because it requires a rather large input document from:
https://drive.google.com/file/d/1OkIq3XJuKiFfKDWBIcAk8_fLLjpNkuHQ/view?usp=sharing

It's non-trivial to download from this url, so we only do anything if
environment variable PYMUPDF_TEST_4918_PATH is set to local path of the
input document.

As of 2026-06-04 this passes with mupdf master, but segvs with current
pymupdf release 1.27.2.3.
'''
PYMUPDF_TEST_4918_PATH = os.environ.get('PYMUPDF_TEST_4918_PATH')
if not PYMUPDF_TEST_4918_PATH :
print(f'test_4918(): Doing nothing because {PYMUPDF_TEST_4918_PATH=}.')
return
path = PYMUPDF_TEST_4918_PATH
print(f'{path=}')
with pymupdf.open(path) as document:
document.rewrite_images(dpi_threshold=150, dpi_target=100, quality=50)
18 changes: 18 additions & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,21 @@ def test_4965():
print(f' {name=}')
print(f' {value=}')
print(f' {f_type=}')


def test_4114():
print()
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4114.pdf')
path_out = os.path.normpath(f'{__file__}/../../tests/test_4114_out.pdf')
expected_values = [' - Select One - ', ' ', 'Cincinnati, OH 45999', 'Memphis, TN 37501', 'Ogden, UT 84201', 'Philadelphia, PA 19255']
expected_values2 = [expected_values, expected_values]
values = list()
with pymupdf.open(path) as document:
for page_i, page in enumerate(document):
for widget in page.widgets():
if widget.field_type_string == 'ComboBox':
print(f'test_4114(): {page_i=} {widget.choice_values=}')
values.append(widget.choice_values)
widget.update()
document.save(path_out)
assert values == expected_values2
Loading