-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
4 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/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 |