comparison tests/test_linebreaks.py @ 1:1d09e1dec1d9 upstream

ADD: PyMuPDF v1.26.4: the original sdist. It does not yet contain MuPDF. This normally will be downloaded when building PyMuPDF.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:37:51 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 1:1d09e1dec1d9
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