mirror of
https://github.com/jsvine/pdfplumber.git
synced 2026-08-29 16:40:24 +08:00
7e2dc7cf75
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.
29 lines
806 B
Python
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
|