pdfminer.six/tests/test_layout.py

24 lines
883 B
Python
Raw Normal View History

import unittest
from pdfminer.layout import LTLayoutContainer, LAParams, LTTextLineHorizontal
class TestGroupTextLines(unittest.TestCase):
def test_parent_with_wrong_bbox_returns_non_empty_neighbour_list(self):
"""
LTLayoutContainer.group_textlines() should return all the lines in a
separate LTTextBoxes if they do not overlap. Even when the bounding box
of the parent container does not contain all the lines.
"""
laparams = LAParams()
layout = LTLayoutContainer((0, 0, 50, 50))
line1 = LTTextLineHorizontal(laparams.word_margin)
line1.set_bbox((0, 0, 50, 5))
line2 = LTTextLineHorizontal(laparams.word_margin)
line2.set_bbox((0, 50, 50, 55))
lines = [line1, line2]
textboxes = list(layout.group_textlines(laparams, lines))
self.assertEqual(len(textboxes), 2)