diff --git a/src/utils.py b/src/utils.py index 229cea266..3d7d10e25 100644 --- a/src/utils.py +++ b/src/utils.py @@ -2105,8 +2105,7 @@ def insert_htmlbox( scale_max = None if scale_low == 0 else 1 / scale_low fit = story.fit_scale(temp_rect, scale_min=1, scale_max=scale_max) - - if fit.big_enough is False: # there was no fit + if not fit.big_enough: # there was no fit return (-1, scale_low) filled = fit.filled diff --git a/tests/test_textbox.py b/tests/test_textbox.py index e0bda416e..37f1e5ec9 100644 --- a/tests/test_textbox.py +++ b/tests/test_textbox.py @@ -271,3 +271,11 @@ def test_3559(): text_insert="""

""" rect = pymupdf.Rect(100, 100, 200, 200) page.insert_htmlbox(rect, text_insert) + + +def test_3916(): + doc = pymupdf.open() + rect = pymupdf.Rect(100, 100, 101, 101) # Too small for the text. + page = doc.new_page() + spare_height, scale = page.insert_htmlbox(rect, "Hello, World!", scale_low=0.5) + assert spare_height == -1