comparison tests/test_linebreaks.py @ 3:2c135c81b16c

MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:44:09 +0200
parents 1d09e1dec1d9
children
comparison
equal deleted inserted replaced
0:6015a75abc2d 3:2c135c81b16c
1 import pymupdf
2
3 import os.path
4
5
6 def test_linebreaks():
7 """Test avoidance of linebreaks."""
8 path = os.path.abspath(f"{__file__}/../../tests/resources/test-linebreaks.pdf")
9 doc = pymupdf.open(path)
10 page = doc[0]
11 tp = page.get_textpage(flags=pymupdf.TEXTFLAGS_WORDS)
12 word_count = len(page.get_text("words", textpage=tp))
13 line_count1 = len(page.get_text(textpage=tp).splitlines())
14 line_count2 = len(page.get_text(sort=True, textpage=tp).splitlines())
15 assert word_count == line_count1
16 assert line_count2 < line_count1 / 2