Commit Graph

137 Commits

Author SHA1 Message Date
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
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 cc3081a619 Thank @toshi1127 2023-02-13 21:52:57 -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 4e04dae219 Give text-extraction own section in README 2023-02-07 17:07:46 -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 dbaf0cce53 Add note on to_image re. FilteredPage 2023-01-10 03:55:01 -05:00
wltrhslu d45eced209 Update README.md
Change broken ghostscript installation link
2022-12-08 17:01:09 +01:00
Jeremy Singer-Vine 6d71c2e25b Merge branch 'stable' into develop 2022-09-19 14:47:43 -04:00
Jeremy Singer-Vine ed2eb49f03 Update comparison to PyPDF2 (h/t @tjex)
As of April 2022, the project has been "reborn":
https://pypdf2.readthedocs.io/en/latest/meta/history.html
2022-09-19 14:45:53 -04:00
Jeremy Singer-Vine cab5c5fe22 Make im.show() usage a bit clearer. 2022-09-06 19:20:45 -04:00
Jeremy Singer-Vine 5c7787b771 Add PageImage.show() (#715)
A simple method, just an alias to PageImage.annotated.show(), which uses
https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.show

Inspired by @osephernest's question in
https://github.com/jsvine/pdfplumber/discussions/715
2022-08-22 17:49:31 -04:00
Jeremy Singer-Vine 446abb7dd1 Add consulting note to README.md 2022-07-22 15:29:04 -04:00
Jeremy Singer-Vine 3ab1cc4377 Add utils/Page.outside_bbox(...)
See https://github.com/jsvine/pdfplumber/issues/369
2022-07-20 17:10:35 -04:00
Jeremy Singer-Vine 71ad60f891 Add strict=True/False to .crop/within_bbox(...)
See https://github.com/jsvine/pdfplumber/issues/421
2022-07-20 15:16:03 -04:00
Jeremy Singer-Vine b00cbbe3aa Thank @lolipopshock in README.md 2022-07-16 17:22:06 -04:00
Shannon Shen 5193c26c31 Consider punctuation when extracting words (#682)
Adds an optional argument to the `extract_words` function that allows to enforce breaking tokens at punctuation. PR by @lolipopshock.
2022-07-16 09:58:10 -04:00
Jeremy Singer-Vine 6d4eec829a Add link to Chinese translation 2022-07-14 17:45:01 -04:00
Jeremy Singer-Vine cfa0a38e30 Update list of tested Python versions 2022-07-14 17:37:00 -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 f4f7e66c94 Add thanks to @jhonatan-lopes 2022-05-24 13:45:53 -04:00
Jeremy Singer-Vine 1262f6cfb4 Add README note re. .search(...) kwargs 2022-05-14 17:43:36 -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 ae6f99e691 Add char['matrix'], ctm submodule, and CTM class 2022-05-10 18:09:44 -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
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 cbb34ce28b Add join_x/y_tolerance to table extract. settings
Now all tolerance settings have x/y versions as well.

This commit also changes `table.merge_edges(...)` behavior when
`join_tolerance` (and `x`/`y` variants) `<= 0`, so that joining is
attempted regardless, to handle cases of overlapping lines.
2021-12-01 23:30:12 -05:00
Jeremy Singer-Vine 7ed4742f8f Add snap_x/y_tolerance to table-extract. settings
Based largely on @dustindall's work in PR #51, adapted to current code.

Also resolves issue #475.
2021-12-01 09:51:20 -05:00
Jeremy Singer-Vine 1252727042 Replace None w/ default in table_settings docs
Per @samkit-jain suggestion in PR #545
2021-11-28 13:31:39 -08:00
Jeremy Singer-Vine d235d4bbc4 Add experimental .extract_text(layout=True)
See the docstring in utils.words_to_layout for details on the
implementation.

Addresses issue #10 and related issues.
2021-11-02 23:12:17 -04:00
Jeremy Singer-Vine 87b947f8f6 Remove decimalizing (but let CLI adjust precision)
Per discussion at https://github.com/jsvine/pdfplumber/discussions/346
and input from @ramcdona, this commit changes pdfplumber's behavior
regarding floating point numbers. Specifically, it removes all
conversion of floats to Decimal objects. This brings several advantages:

- Increased precision (where applicable)
- Decreased code complexity
- Increased performance (~10% speedup on test suite)
- Increased fidelity to `pdfminer.six` output

These seem to outweigh the disadvantages:

- Some tests break (but have been easily fixed) due to increased
  precision and/or floating point arithmetic artifacts
- Some users' scripts may also break, if they depend on strict equality
  testing, though these *should* also be easily fixable

Because some form of automatic rounding may still be desirable for the
pdfplumber CLI utility, the conversion methods (.to_csv, .to_json) have
been adjusted to accept a `precision` argument.
2021-10-19 21:51:33 -04:00
Jeremy Singer-Vine 901985407b Tweak #467 code slightly, update CHANGELOG/thanks
h/t @bobluda + @samkit-jain
2021-07-15 10:01:17 -04:00
Jeremy Singer-Vine 7bd9d2624e Update CHANGELOG and add @trifling to contribs 2021-05-08 17:44:14 -04:00
Jeremy Singer-Vine 237742039d Add --laparams to CLI (and make related tweaks)
This commit adds an `--laparams` flag to the pdfplumber CLI, giving it
more feature parity with the core library. To do so, it makes some
internal changes to `convert.py`, including changing the list of objects
to convert from *a predefined default list* to *all types extracted*.
2021-04-08 09:43:33 -04:00
Jeremy Singer-Vine 694f9193cc Update CHANGELOG.md and thank @alexreg 2021-03-19 19:08:32 -04:00
Jeremy Singer-Vine 5bf32987b8 Update CHANGELOG and fix double-space in README 2021-02-28 14:15:45 -05:00
Jeremy Singer-Vine 7e2dc7cf75 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.
2021-02-26 18:53:11 -05:00
Jeremy Singer-Vine 2caba6a1f4 Clarify meaning of .curves 2021-02-10 21:53:12 -05:00
Jeremy Singer-Vine b1849f4193 Move __enter__/__exit__/.close to Container class
So that they apply not only to the PDF class, but to the Page class as
well. Enables things such as:

```
for page in pdf.pages:
    do_something()
    page.close()
```

... and:

```
for page in pdf.pages:
    with page:
        do_something()
```
2021-02-10 09:48:44 -05:00
Jeremy Singer-Vine 1426a84f5a Move troubleshooting/Q&A to "Discussions"
- Makes this clearer in README.md
- Removes the "troubleshooting" issue template
- Adds a .github/ISSUE_TEMPATE/config.yml that disables blank issues and
  directs non-bug, non-feature-request discussions to the Discussions
  forum
2021-02-05 10:04:20 -05:00
Samkit Jain d352280fe0 Make metadata parse failure handling behaviour configurable 2020-12-08 22:38:22 +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 3c5041a20b [docs] Fix broken link README's CLI example #264
Thanks to @flaprocha for spotting this.
2020-09-01 09:02:05 -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 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 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