Commit Graph

475 Commits

Author SHA1 Message Date
Jeremy Singer-Vine 12feadb8fd Fix bug in LayoutEngine.calculate(...)
The problem had been that `LayoutEngine.calculate(...)` was assuming
that len(char["text"]) would always equal 1, which is not true for
ligatures.

Thanks to @samkit-jain for finding a PDF that raised the error, and to
@bpugnaire for raising issue #683.
2022-07-14 17:21:55 -04:00
Jeremy Singer-Vine fd3f5334f8 Bump version to 0.7.1 v0.7.1 2022-05-31 15:53:26 -04:00
Jeremy Singer-Vine 0475819d73 Update CHANGELOG.md 2022-05-31 15:52:50 -04:00
Jeremy Singer-Vine ef065a72e5 Add Makefile target and reqs for examples 2022-05-31 15:50:50 -04:00
Jeremy Singer-Vine 063e2edd75 Fix #659 (PageImage.debug_tablefinder())
Thanks to @rneumann7 for flagging!
2022-05-31 15:45:40 -04:00
Jeremy Singer-Vine a0988aa963 Add missing h/t to CHANGELOG.md 2022-05-27 15:02:19 -04:00
Jeremy Singer-Vine cec6e0feb0 Bump version to 0.7.0 v0.7.0 2022-05-27 14:54:28 -04:00
Jeremy Singer-Vine 23d449badc Update CHANGELOG.md 2022-05-27 14:53:43 -04:00
Jeremy Singer-Vine ad3df11954 Fix .extract_text(layout=True) for text-less pages
Fixes https://github.com/jsvine/pdfplumber/issues/658

Thanks to @ethanscorey for flagging!
2022-05-27 14:41:57 -04:00
Jeremy Singer-Vine 486cea840a Bump pdfminer.six to version 20220524 2022-05-24 13:48:57 -04:00
Jeremy Singer-Vine f4f7e66c94 Add thanks to @jhonatan-lopes 2022-05-24 13:45:53 -04:00
Jhonatan Lopes ca795d19c4 Add py.typed marker for PEP 561 compatibility (#657)
Via PR by @jhonatan-lopes.
2022-05-24 13:43:42 -04:00
Jeremy Singer-Vine b39fc46cb6 Tweak CTM desc. in CHANGELOG slightly 2022-05-17 11:01:49 -04:00
Jeremy Singer-Vine 1262f6cfb4 Add README note re. .search(...) kwargs 2022-05-14 17:43:36 -04:00
Jeremy Singer-Vine 4deac2522d Add --include/exclude-attrs to CLI & serialization
For `Serializer`, `.to_json(...)` and `.to_csv(...)`, the params are
`include_attrs`, and `exclude_attrs`.
2022-05-14 12:07:44 -04:00
Jeremy Singer-Vine 826e927b7f Remove redundant loading in test_basics.py 2022-05-13 16:42:23 -04:00
Jeremy Singer-Vine 9f11de3b4d @lru_cache -> @lru_cache() to appease Python 3.7 2022-05-13 16:26:13 -04:00
Jeremy Singer-Vine 24f3532813 Remove utils.collate_chars(...)
This was the previous name (and then alias) for utils.extract_text(...),
and hasn't been featured in the documentation in a long time.
2022-05-13 16:10:13 -04:00
Jeremy Singer-Vine 58b1ab1b0a Add (experimental) page.search(...) feature
First proposed here: https://github.com/jsvine/pdfplumber/issues/201

Adding this feature involved refactoring and re-engineering a good chunk
of the text-layout-extraction code. As part of that, this commit
introduces two new classes, in utils.py: LayoutEngine and TextLayout.
They should be considered provisional, and may change name/approach in
the future.
2022-05-13 16:04:03 -04:00
Jeremy Singer-Vine 056b8310db Add to README: stroking_color / non_stroking_color 2022-05-13 15:22:41 -04:00
Jeremy Singer-Vine 75462f81e1 Remove unnecessary assignment 2022-05-11 09:57:15 -04:00
Jeremy Singer-Vine ae6f99e691 Add char['matrix'], ctm submodule, and CTM class 2022-05-10 18:09:44 -04:00
Jeremy Singer-Vine 3191c25c83 Bump version to 0.6.2 v0.6.2 2022-05-06 13:59:59 -04:00
Jeremy Singer-Vine 3cf4e6faac Update CHANGELOG.md 2022-05-06 13:59:13 -04:00
Jeremy Singer-Vine 1b7458a795 Tweak test_display.py:test__repr_png_ 2022-05-06 13:54:58 -04:00
Jeremy Singer-Vine b013e9bd66 Downgrade pandas in reqs-dev, for Py3.7 testing 2022-05-06 13:36:52 -04:00
Jeremy Singer-Vine 0c4a9e5ec3 Add --profile black to isort in GH action 2022-05-06 13:31:39 -04:00
Jeremy Singer-Vine feb9d082d7 Add final bits of test coverage
Added weak tests for a couple of hard-to-test visual debugging methods
in display.py.

Also marked an exception-handling block in pdf.py as `pragma: nocover`
because we don't yet have a PDF to test it with, but the logic there is
simple and straightforward.
2022-05-06 10:19:48 -04:00
Jeremy Singer-Vine a7af394308 Update CHANGELOG.md 2022-05-06 10:17:14 -04:00
Jeremy Singer-Vine cdfdb87a21 Enforce type annotations via mypy --strict
Enforcement added via:
- The repo's Makefile (`make check-mypy` & `make lint`)
- The repo's main GitHub Action
2022-05-06 09:51:01 -04:00
Jeremy Singer-Vine 9587cc7d22 Add type annotations and refactor accordingly
A fairly large commit, adding type annotations/hints to the entire
library, and refactoring the library accordingly.

Most of the refactoring changes should have no practical effect on
usage, but several others are notable:

- Added `TableSettings` class, a behind-the-scenes handler for managing
  and validating table-extraction settings.
- Renamed the positional argument to `.to_csv(...)` and `.to_json(...)`
  from `types` to `object_types`.
- Tweaked the output of `.to_json(...)` so that, if an object type is
  not present for a given page, it has no key in the page's object
  representation.
- Removed `utils.filter_objects(...)` and move the functionality to
  within the `FilteredPage.objects` property calculation, the only part
  of the library that used it.
- Removed code that sets `pdfminer.pdftypes.STRICT = True` and
  `pdfminer.pdfinterp.STRICT = True`, since that [has now been the
  default for a
  while](https://github.com/pdfminer/pdfminer.six/commit/9439a3a31a347836aad1c1226168156125d9505f).
2022-05-06 09:43:50 -04:00
Jeremy Singer-Vine 18a27516c5 Bump version to 0.6.1 v0.6.1 2022-04-23 17:10:04 -04:00
Jeremy Singer-Vine bc7864a08b Update CHANGELOG.md 2022-04-23 17:09:00 -04:00
Jeremy Singer-Vine a32473ee5f Change supported Python: cut 3.6, add 3.9 & 3.10
(Python EOL'ed version 3.6 in December 2021.)
2022-04-23 17:02:47 -04:00
Jeremy Singer-Vine 3db4bb0614 Tweak test_laparams.py for pdfminer.six==20220319 2022-04-23 16:46:10 -04:00
Jeremy Singer-Vine 32de149137 Update CHANGELOG.md 2022-04-22 20:02:53 -04:00
Jeremy Singer-Vine 8a333e64c1 Upgrade pinned psf/black formatter version 2022-04-22 19:57:20 -04:00
Jeremy Singer-Vine e434ed0b19 Bump pinned pdfminer.six version to 20220319 2022-04-22 19:46:04 -04:00
Jeremy Singer-Vine d88eff1e53 Bump minimum Pillow version 2022-04-22 19:41:41 -04:00
Jeremy Singer-Vine 0dc57537c8 Fix incompatibility with Pillow>=9.1 (#637)
Simple fix, passing tuple instead of map iterator.

h/t @tye-shutty for flagging
2022-04-22 19:38:06 -04:00
Jeremy Singer-Vine 5731edc58a Fix broken link re ghostscript installation (#608)
Thanks to @vmgottin for flagging!
2022-03-02 19:49:32 -06:00
Jeremy Singer-Vine a260dc54c0 Add sudo apt update to GH workflow 2022-01-14 19:01:34 -05:00
Jeremy Singer-Vine 57ef25f2d3 Add PR 581 to CHANGELOG.md 2022-01-13 23:21:43 -05:00
Jeremy Singer-Vine b21ae179fe Add tests for PR 581
We cannot test whether the file closed successfully, but we can test
that the code reaches that branch of the logic.
2022-01-13 23:21:43 -05:00
Jeremy Singer-Vine cf716e0d35 Refactor .open(...) for clarity
No change to behavior.
2022-01-13 23:21:43 -05:00
augeos-grosso f7417bc38a Address issue #578 (PR #581)
Add try-except block in open() (#578), by @augeos-grosso / @johnhuge
2022-01-13 23:15:41 -05:00
Jeremy Singer-Vine b904dd6a7c Tweak/rerun example notebooks, to match 0.6.0
Just a few small changes required, after five years of not being
updated. Each notebook also now prints the pdfplumber version it uses.
2021-12-24 13:29:47 -05:00
Jeremy Singer-Vine 6c8a46b6b0 Remove unnecessary conditional in utils.clip_obj() 2021-12-23 22:32:31 -05:00
Jeremy Singer-Vine 3f6a724c20 Merge pull request #575 from fristhon/stable
Refactor
2021-12-23 22:16:00 -05:00
Mohammadreza Jafari 8fd79fb485 Refactor utils.py 2021-12-22 12:58:55 +03:30