Commit Graph

308 Commits

Author SHA1 Message Date
Jeremy Singer-Vine 08cf2ec8e1 Link extra_attrs documentation to list of props
h/t @samkit-jain for the suggestion
2020-08-30 13:29:51 -04:00
Jeremy Singer-Vine 5d51940bbb [changelog] Hyperlink & standardize commit hashes
h/t @samkit-jain for the suggestion
2020-08-30 13:29:33 -04:00
Jeremy Singer-Vine b050870824 Reformat page.py (per newer version of psf/black) 2020-08-29 16:27:14 -04:00
Jeremy Singer-Vine 0eaaf91ebd Update CHANGELOG.md 2020-08-29 16:21:28 -04:00
Jeremy Singer-Vine c8b200ee7c Refactor .extract_words and allow attrib-grouping
This commit refactors and hopefully makes clearer the logic in
utils.extract_words. It also adds a new parameter, `extra_attrs`, which
allows the user to pass a list of attributes on which to group all
characters.

For instance, passing `extra_attrs=["fontname", "size"]` will not allow
characters with different font names or sizes to become part of the same
word. As a benefit, those resulting word dicts will contain `"fontname"`
and `"size"` attributes — providing a long-requested feature (cf. issue
2020-08-29 16:05:31 -04:00
Jeremy Singer-Vine 6233bbd6ed Speed up test_ca_warn_report:test_objects
The same goals can be acheived by just testing the first page, instead
of the entire PDF, trimming approximately 20% off the total test suite's
execution time, although YMMV.
2020-08-29 13:35:47 -04:00
Jeremy Singer-Vine 917467a10c Remove test_issues.py:test_pr_77 to speed up tests
The test, responding to PR #77, was particularly slow and the
accompanying PDF somewhat large. Now that the fixes to the issues
identified in the PR are fairly tightly integrated into pdfplumber, we
can remove the tests with reasonable confidence, speeding up development
time.
2020-08-29 13:31:42 -04:00
Jeremy Singer-Vine 1f87898857 Refactor/simplify Page.process_objects
This commit reworks the Page.process_objects method to be less complex
and more readable. Many of the changes stem from a realization that
pdfminer.six already stores most object attributes in the desired type;
we only need to convert those requiring decimalization.

This results in one notable change to the output, which is that
`upright` is no longer converted from a bool to an int. The necessary
downstream changes are reflected in utils.extract_words and convert.py.

Overall the changes result in no substantial change to performance; it
is possible that the code runs ever-so-slightly faster, but to a barely
detectable degree.
2020-08-29 13:25:34 -04:00
Jeremy Singer-Vine 8e74cb9553 Remove reference/access to .figures
Per diagram and explanation in [1], LTFigure is just a layout-estimated
collation of LTCurve objects. For consistency with the rest of
pdfplumber, removing it from the list of parsed/accessible objects,
although we still do process the curves within each figure.

[1] https://github.com/pdfminer/pdfminer.six/blob/develop/docs/source/topic/converting_pdf_to_text.rst
2020-08-26 08:49:30 -04:00
Jeremy Singer-Vine a74d3bc7e1 Reduce McCabe complexity of convert.serialize(...) 2020-08-25 22:40:44 -04:00
Jeremy Singer-Vine 59a7dd2100 [docs] Note PyMuPDF's lack of easy shape-access 2020-08-25 22:18:40 -04:00
Jeremy Singer-Vine 9b40f35f0a [docs] Fix typo 2020-08-21 09:46:08 -04:00
Jeremy Singer-Vine d2f5896dac Merge pull request #258 from jsvine/develop
Add comparisons to other Python PDF libraries
2020-08-21 09:42:34 -04:00
Jeremy Singer-Vine 23bebf4c16 Merge branch 'develop' into stable 2020-08-21 09:38:04 -04:00
Jeremy Singer-Vine e2539786b5 [docs] Add comparison to other libraries (#257)
Thanks to @MartinThoma for the idea.
2020-08-21 09:32:41 -04:00
Jeremy Singer-Vine c2f92a9a8e [docs] Tweak note re. former Python 3.5 support 2020-08-21 09:32:07 -04:00
Jeremy Singer-Vine a7df740d1f Merge pull request #256 from jsvine/develop
Merge v0.5.23 into stable branch
2020-08-15 13:03:21 -04:00
Jeremy Singer-Vine d2e7cfdc1b Bump to v0.5.23 🎉 v0.5.23 2020-08-15 12:55:30 -04:00
Jeremy Singer-Vine fb45890bc5 Update changelog 2020-08-15 12:55:12 -04:00
Jeremy Singer-Vine 4f60d9e3bb Remove .travis.yml & link README to Actions tests 2020-08-15 12:13:37 -04:00
Samkit Jain 3b1e23a23a Use f-strings for string formatting 2020-08-15 12:03:34 -04:00
Samkit Jain baf103307b Drop support for Python 3.5 2020-08-15 12:03:34 -04:00
Samkit Jain 1aa921b39c Split the main GA job into 2 separate linting and testing jobs 2020-08-15 12:03:34 -04:00
Jeremy Singer-Vine a5e7d7fa52 Remove pandas from dev requirements and tests
Results in needing one more # pragma: nocover statement, but on a
simple line of code. See PR #253 for details and motivation.
2020-08-15 12:03:34 -04:00
Samkit Jain 90f767ff24 Update GitHub Actions workflow 2020-08-15 12:03:34 -04:00
Jeremy Singer-Vine 798a152156 [README] Remove email address, add maintainer list 2020-08-15 09:18:40 -04:00
Jeremy Singer-Vine d8a2f93098 Fix: Raise ValueError on crop w/ zero-overlap bbox
h/t @samkit-jain for catching, per example in #245
2020-08-15 09:18:00 -04:00
Jeremy Singer-Vine 3786b1adec Reformat recent code per psf/black 2020-08-13 22:31:53 -04:00
Jeremy Singer-Vine ddafd627f4 Update changelog 2020-08-13 22:29:30 -04:00
Jeremy Singer-Vine 047ad345b4 Add relative param to .crop & err on invalid boxes
Addresses https://github.com/jsvine/pdfplumber/issues/245

Also adds `relative` param to .within_bbox, and adds a new
utils.calculate_area(bbox) method.
2020-08-13 22:25:58 -04:00
Jeremy Singer-Vine 6c9f8db9b6 Fix CLI test & GitHub action 2020-08-13 21:35:06 -04:00
Jeremy Singer-Vine 76583d9f33 Add make lint 2020-08-13 08:58:13 -04:00
Jeremy Singer-Vine 6d88c5dc6e Fix flake8 violations & .serialize's decode logic 2020-08-13 08:57:06 -04:00
Jeremy Singer-Vine fb0c607985 Update changelog 2020-08-13 08:42:40 -04:00
Jeremy Singer-Vine 853aea2f2b Reflect (prior) shift to using only pdfminer.six 2020-08-13 08:40:07 -04:00
Jeremy Singer-Vine cbc91c67d0 Add convert.py/.to_json/.to_csv & improve testcov
Moves most of the logic previously in cli.py to convert.py, for usage by
other submodules. Adds Container.to_json and Container.to_csv. Makes
adjustments/fixes to other parts of the library, based on edge-cases
encountered (such as infinite recursion in anntations).
2020-08-13 08:37:46 -04:00
Jeremy Singer-Vine 3f4b4b24b3 Bring pdfplumber/table.py coverage to 100% 2020-08-06 22:19:40 -04:00
Jeremy Singer-Vine f0c9b85f18 Fix typo in "lines_strict" strat.; wasn't working 2020-08-06 22:18:34 -04:00
Jeremy Singer-Vine 850c5d6c61 Cut TableFinder's redund. recheck of x/y-tolerance 2020-08-06 22:16:49 -04:00
Jeremy Singer-Vine d224202bdf Simplify words_to_edges_h & (esp) words_to_edges_v 2020-08-06 22:15:35 -04:00
Jeremy Singer-Vine 57d54ee272 Tweak .gitignore 2020-08-06 22:14:20 -04:00
Jeremy Singer-Vine 59aad6b8fb Add coverage html to Makefile's tests target 2020-08-06 22:13:48 -04:00
Jeremy Singer-Vine 5271244d76 Update changelog 2020-08-05 23:11:03 -04:00
Jeremy Singer-Vine 8320d6479d Change .move_to_avg to .snap_objects & mv to utils
Also: Simplify the function, and make it based on the attribute you want
to snap *to*, not just the axis/orientation across which to snap.
2020-08-05 22:52:36 -04:00
Jeremy Singer-Vine f991e241ff Small edit to appease psf/black 2020-08-01 12:32:54 -04:00
Jeremy Singer-Vine d16aa13ca2 Fix utils.extract_words & .resize_object, + tests
- Fixes `.extract_words`, which had been returning incorrect results when `horizontal_ltr = False`
- Fixes `.resize_object`, which had been failing in various permutations
- Brings utils.py test coverage to 100%
2020-08-01 12:27:07 -04:00
Jeremy Singer-Vine 8e2a166c56 Add coverage for one missing pdf.page method 2020-08-01 10:21:17 -04:00
Jeremy Singer-Vine e7bd308fea Refactor DerivedPage classes & fully test page.py
Previously, classes were being defined dynamically, in a confusing
manner. This new logic should be easier to understand.

This commit also adds a few assertions that bring coverage for page.py
to 100%.
2020-08-01 09:19:27 -04:00
Jeremy Singer-Vine 5cbc2da7a7 Merge pull request #241 from jsvine/fix/annots
Add `.annots` and `.hyperlinks`, replacing .annos
2020-08-01 09:03:45 -04:00
Jeremy Singer-Vine aa03961291 Add .annots and .hyperlinks, replacing .annos
.annos was non-functional, based on a misunderstanding of how
Annotation objects were represented in the PDF object. Also shifts
language from "annos" to "annots" to mirror pdfminer's nomenclature.
2020-07-31 18:02:04 -04:00