Commit Graph

25 Commits

Author SHA1 Message Date
Samkit Jain b132d45db5 Fix bug in dedup_chars() in which ._objects was accessed before assignment
Fixes #293
2020-10-20 17:02:07 +05:30
Jeremy Singer-Vine 04fd56ac40 Add utils/page.dedupe_chars(...) (#71 + #280)
h/t @xv44586 for the initial inspiration 👍

These new methods return a version of the chars/page with duplicate
chars — those sharing the same text, fontname, size, and positioning
(within `tolerance` x/y) as other characters — removed.
2020-10-03 12:06:48 -04:00
Jeremy Singer-Vine 84f91811df Rework .extract_words and add use_text_flow param
Taking @samkit-jain's smart question about sort-order into account, this
commit reworks `.extract_words`, making the sorting more explicit, and
adding an option to *not* sort, via `use_text_flow=True`, which follows
the original PDF's text flow, rather than presorting all characters top-down,
left-right.

To do so required rethinking the word-delineation logic,
which in turn motivated a shift toward a more object-oriented approach
(especially to keep track of settings without passing them from function
to function). Now `.extract_text`'s logic is encapsulated in a new class,
`TextExtractor`.
2020-08-30 18:36:03 -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 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
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 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 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
Jeremy Singer-Vine 85f422d001 Fix bug in pdfminer.six's .resolve_all
See https://github.com/jsvine/pdfplumber/issues/203

Root cause of decimalization bug flagged in that issue was
pdfminer.six's .resolve_all method not recusively resolving items within
tuples. Now we define our own method, with some slight optimization
tweaks.
2020-04-29 08:31:39 -04:00
Jeremy Singer-Vine 6c2e474490 Update pdfminer.six/pillow reqs & bump to v0.5.15 2020-01-05 21:33:49 -05:00
Jeremy Singer-Vine 4ef679d6d7 Add test for PR 136 and bump version 2019-08-29 19:05:23 -04:00
Jeremy Singer-Vine 6f70d0937a Add support for parsing password-protected PDFs
Thanks to @nikhilbhawsinka for raising the question in
https://github.com/jsvine/pdfplumber/issues/101

Test PDF via https://www.novapdf.com/pdf-example-files-created-with-novapdf-kb.html
2019-04-14 23:19:16 -04:00
Jeremy Singer-Vine 5843cd7572 Improve PDFObjRef resolution and object conversion
More robust solutions to:

- https://github.com/jsvine/pdfplumber/pull/77
- https://github.com/jsvine/pdfplumber/issues/90
2018-11-11 22:28:46 -05:00
Jeremy Singer-Vine 416fda35d2 Resolve PR #77 (decimalize + PDFRefObj) 2018-11-08 22:59:39 -05:00
Jeremy Singer-Vine f8fdd27d3d Add test for PR 88 and thank @OisinMoran 2018-11-08 22:27:59 -05:00
Jeremy Singer-Vine 8ea688702d Add test for issue #67 / PR #69
Thanks to @yiqiyu for the example PDF!
2018-07-10 22:57:14 -04:00
Jeremy Singer-Vine b0f094c6f9 Don't decimalize (non_)stroking_color, fixing #53 2018-03-06 08:44:59 -05:00
Jeremy Singer-Vine c9e45ce067 Fix issue #33 by checking decode_text arg type 2017-05-10 22:52:52 -04:00
Jeremy Singer-Vine ba9d7ab0c8 Add test for issue #13
Thanks to @jsfenfen: https://github.com/jsvine/pdfplumber/issues/13
2017-02-25 14:39:47 -05:00
Jeremy Singer-Vine 955b126b80 v0.5.0
- Completely overhauls the approach to table extraction.
- Adds visual debugging.
- See CHANGELOG.md for details.
2017-02-25 13:30:50 -05:00
Jeremy Singer-Vine fcccd8e2d3 Merge branch 'master' into develop 2017-01-26 16:21:55 -05:00
Jeremy Singer-Vine 302b8a72ad Fix resolution/decoding of list-type metadata
Big thanks to @jeffbarrera for flagging:
https://github.com/jsvine/pdfplumber/issues/14
2016-05-24 16:41:03 -04:00
Jeremy Singer-Vine ee98c6d1e8 Add test for CA WARN report, h/t @dannguyen 2016-04-23 21:06:33 -04:00
Jeremy Singer-Vine 3a0fdad4c1 Add Los Angeles precinct bulletin test 2016-02-28 18:50:33 -05:00
Jeremy Singer-Vine 74bf8178f9 Add first test 2016-02-20 19:44:05 -05:00