Files
pdfplumber/tests/test_laparams.py
T
Jeremy Singer-Vine 7e2dc7cf75 Re-add textboxhorizontal/etc. when laparams (#359)
This commit reinstates access to higher-level layout objects (such as
`textboxhorizontal`) when `laparams` is passed to
`pdfplumber.open(...)`. Had been removed in `0.5.24` via 1f87898.

Also adds a test for this behavior.
2021-02-26 18:53:11 -05:00

29 lines
806 B
Python

#!/usr/bin/env python
import unittest
import pdfplumber
import os
import logging
logging.disable(logging.ERROR)
HERE = os.path.abspath(os.path.dirname(__file__))
class Test(unittest.TestCase):
@classmethod
def setup_class(self):
self.path = os.path.join(HERE, "pdfs/issue-13-151201DSP-Fond-581-90D.pdf")
def test_without_laparams(self):
with pdfplumber.open(self.path, laparams=None) as pdf:
objs = pdf.pages[0].objects
assert "textboxhorizontal" not in objs.keys()
assert len(objs["char"]) == 4408
def test_with_laparams(self):
with pdfplumber.open(self.path, laparams={}) as pdf:
objs = pdf.pages[0].objects
assert len(objs["textboxhorizontal"]) == 21
assert len(objs["char"]) == 4408