Commit Graph

615 Commits

Author SHA1 Message Date
Ritchie Poh 8bf51217bc Update README.md
Fixed a small typo
2023-05-02 14:46:16 +08:00
Jeremy Singer-Vine ae676aeacd Add PNG-length alternatives to tests 2023-04-20 06:10:42 -04:00
Jeremy Singer-Vine 255eaaced7 Merge pull request #862 from jsvine/develop
v0.9.0
v0.9.0
2023-04-13 08:56:13 -04:00
Jeremy Singer-Vine 3e0f9d782e Rerun examples/notebooks for v0.9.0 (incl one fix)
(`san-jose-pd-firearm-report.ipynb` needed a one-param fix, after not
having been updated in a few versions.)
2023-04-13 08:41:11 -04:00
Jeremy Singer-Vine 1a8603bd1b Bump version to v0.9.0 2023-04-13 08:40:52 -04:00
Jeremy Singer-Vine 86e935d681 By default, expand ligatures into their letters
Addresses issue #598
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine f042d5c246 Remove line of code that does nothing 2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 6f6b465260 Add .curve_edges, use by default in table-detect.
Most of the groundwork was already there to add a PDF/Page.curve_edges
property. And, inspired, by
https://github.com/jsvine/pdfplumber/discussions/858 and related issues,
we now include 0/90/180/270-degree oriented curve segments into the
default table-detection strategy. As before, you can still switch to the
"lines_strict" to use only lines defined as such (rather than also using
rect and curve edges).
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 4b373977be Add .extract_text_lines & related .search params
Inspired by https://github.com/jsvine/pdfplumber/discussions/852,
it turns out that .search(...) gets us most of the way, already.

Added a few params (`main_group`, `return_groups`, `return_chars`) to
.search(...) to enable this, which also make that method more generally
flexible.
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 79ec839ebc Label ordered_chars more explicitly as such 2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 6acd580ceb Make char_begins_new_word more explict & rigorous
This commit aims to fix two things:

- The semi-crypticness of the previous version of char_begins_new_word
- The inconsistency (vs. the rest of the approach) in how the method
  was comparing "top" to "bottom" for interline comparisons, instead of
  "top" to "top", as rightly and helpfully pointed out by @bellma-lilly
  in https://github.com/jsvine/pdfplumber/discussions/840

Based on the unit tests, this shouldn't change the output of
`pdfplumber` in the vast majority of use cases. It might affect some
output in edge-cases, for which I apologize for any inconvenience and
which I hope is balanced out by this more consistent approach's benefits
in the long run.
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine ebb93eae15 Simplify char_begins_new_word
Calculating the bounding boxes of the words is, upon reflection and
testing, not necessary. Instead, all we need is the latest character in
the current word.
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 8368954eaa Handle whitespace-only and empty search results
With regular expressions, patterns made up entirely of optional groups
(e.g., r"(dfsdgfwerw)?") can return match objects that are, effectively,
empty. These were being treated as real search results, and throwing
errors in the process. Now they're being treated as non-results.

Separately but relatedly, whitespace-only searches were throwing errors.
This was due to (a) how PDFs generally represent whitespace (implicitly,
rather than explicit space characters), and (b) how pdfplumber
internally represents those spaces while performing layout analysis.
This caused search results to have no explicit bounding box, throwing
errors. Now, similarly to handling empty search results, we handle
all-whitespace search results by considering them to be non-results.
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 9441ff7628 Handle bytes-typed fontnames (fixes #461 + #842)
Came across this bit of code, which helps to solve some of the mystery
in issues #461 and #842:

https://git.ghostscript.com/?p=mupdf.git;a=blob;f=source/pdf/pdf-font.c;h=6322cedf2c26cfb312c0c0878d7aff97b4c7470e;hb=HEAD#l774

Now, for every char's fontname, we:

- Check whether its a `str` or `byte`
    - If the latter, we check whether it's one of the well-known codes from
      the link above
        - If so, we use that (preserving the part, if present, before
          the `+`)
        - If not, we just cast to str
2023-04-13 08:13:16 -04:00
Jeremy Singer-Vine 1d5d646c04 Bump version to v0.8.1 v0.8.1 2023-04-08 10:47:49 -04:00
Jeremy Singer-Vine db136b77cc Fix x0>x1 error for rect fills, per new Pillow
Pillow 9.5 throws an error when you try to draw a rectangle where x0>x1
or top>bottom. For rects with small width or height but thick strokes,
we ended up hitting that error because we were trying to subtract the
stroke width from the area to be filled.
2023-04-08 10:43:48 -04:00
Han cf17ad1c42 Update README.md and example re. pts/points (#856)
Update ag-energy-roundup-curves.ipynb

Update the key name 'point' to 'pts' in the example to the latest version

* 💄

* Update ag-energy-roundup-curves.ipynb

💄
2023-04-07 19:27:47 -04:00
Jeremy Singer-Vine ee48b26099 Tiny tweak to README.md 2023-03-09 10:59:44 -05:00
Jeremy Singer-Vine bc103d8ac2 Merge pull request #835 from jsvine/issue-834
Correct placement of the `close()` method in the documentation
2023-03-09 10:58:48 -05:00
Samkit Jain 490239ac8e Correct placement of the close() method in the documentation
The method belongs to the `PDF` class and not the `Page` class and was in the incorrect section in the README file as pointed out by @sujayvadlakonda
Fixes #834
2023-03-06 12:21:03 +05:30
Jeremy Singer-Vine 25682fff36 Add note re. Wand's handling of "resolution"
Thanks to @jwestwsj for the suggestion in issue #760
2023-02-24 17:28:16 -05:00
Jeremy Singer-Vine b6847ad4cd Bump to v0.8.0 v0.8.0 2023-02-13 22:00:45 -05:00
Jeremy Singer-Vine cc3081a619 Thank @toshi1127 2023-02-13 21:52:57 -05:00
Jeremy Singer-Vine 24cab4d3fe Update CHANGELOG.md 2023-02-13 21:52:42 -05:00
Jeremy Singer-Vine 93f7dbd1a2 Add width & height kwargs to .to_image() #798 2023-02-13 18:49:18 -05:00
Jeremy Singer-Vine c4e1b294bb Allow *all* extract_text kwargs for tables
Any `text_`-prefixed table extraction setting now automatically gets
passed to `.extract_text(...)` via `table.extract(...)`.

This introduces one minor but breaking change, which is that
`keep_blank_chars` (previously, a valid table extraction setting) now
needs to be passed as `text_keep_blank_chars`.
2023-02-13 17:51:33 -05:00
Jeremy Singer-Vine d3662dec06 Mimic text layout better by padding right/bottom
Adds `layout_width` and `layout_height` to `utils.extract_text`, set to
page width and height by default on `page.extract_text`.
2023-02-13 17:38:40 -05:00
Jeremy Singer-Vine 82b93c4ba7 Merge branch 'develop' of github.com:jsvine/pdfplumber into develop 2023-02-13 09:36:31 -05:00
Jeremy Singer-Vine 75e33f8726 Merge pull request #811 from toshi1127/fix/calc_rotation
fix: calculate rotation using 0 when Rotate is None
2023-02-13 09:36:08 -05:00
toshi1127 a3ece0513c fix: calculate rotation using 0 when rotate is None 2023-02-13 11:18:33 +09:00
Jeremy Singer-Vine 4e04dae219 Give text-extraction own section in README 2023-02-07 17:07:46 -05:00
Jeremy Singer-Vine 3424b57612 Refactor text-extraction utilities 2023-02-07 17:06:59 -05:00
Jeremy Singer-Vine 8ed2c7ef06 Remove confusion about kwargs passed to wand.Image
Thanks to @pseudomonas in #798 for flagging.

Decided to go for a stricter approach, given the complexity of getting a
more flexible approach right. But open to PRs that provide the more
flexible approach.
2023-02-03 14:47:01 -05:00
Jeremy Singer-Vine 216bedd00a Refactor handling of pts attribute
In doing so, deprecate the `curve_obj["points"]` attribute, and fix
`PageImage.draw_line(...)`'s handling of diagonal lines.
2023-02-03 14:27:36 -05:00
Jeremy Singer-Vine bad8eea88d Update CHANGELOG.md 2023-01-24 17:31:30 -05:00
Jeremy Singer-Vine 6351d979e9 Reorganize .utils 2023-01-24 17:28:27 -05:00
Jeremy Singer-Vine 4b7f3b5b65 Merge pull request #791 from conitrade/hotfix/typing-hints
fix typing hints to include io.BytesIO
2023-01-19 20:47:07 +01:00
Alexander Sennhauser d4107f62b1 fix typing hints to include io.BytesIO 2023-01-19 13:10:36 +01:00
Jeremy Singer-Vine 639c169a34 Merge branch 'stable' into develop 2023-01-10 03:55:55 -05:00
Jeremy Singer-Vine dbaf0cce53 Add note on to_image re. FilteredPage 2023-01-10 03:55:01 -05:00
Jeremy Singer-Vine c7600f2209 Merge branch 'stable' into develop 2022-12-08 11:49:37 -05:00
Jeremy Singer-Vine 5491dc2c34 Merge pull request #774 from wltrhslu/stable
Update README.md
2022-12-08 11:48:50 -05:00
wltrhslu d45eced209 Update README.md
Change broken ghostscript installation link
2022-12-08 17:01:09 +01:00
Jeremy Singer-Vine 6af87abe6c Add first attempt at CITATION.cff file
Cf. issue #755, thanks to @joaoccruz
2022-11-22 13:10:45 -05:00
Jeremy Singer-Vine f6741d3097 Rerun examples with v0.7.6 v0.7.6 2022-11-22 12:48:19 -05:00
Jeremy Singer-Vine 8b2ae7e92b Bump version to v0.7.6 2022-11-22 12:48:01 -05:00
Jeremy Singer-Vine b2e037f650 Update CHANGELOG.md 2022-11-22 12:47:40 -05:00
Jeremy Singer-Vine 8a0c12652c Restore "text" attr to .textboxhorizontal/etc.
Fix regression introduced in 9587cc7 / v0.6.2.
2022-11-22 12:24:10 -05:00
Jeremy Singer-Vine e63a0385bb Bump pdfminer.six to version 20221105 2022-11-22 10:41:47 -05:00
Jeremy Singer-Vine e3142a0b57 Fix lru_cache usage re. class methods
Cf. https://rednafi.github.io/reflections/dont-wrap-instance-methods-with-functoolslru_cache-decorator-in-python.html
2022-11-21 21:58:08 -05:00