Upgrade pdfminer.six from 20250327 to 20250506

... and adjust color handling accordingly.
This commit is contained in:
Jeremy Singer-Vine
2025-05-16 08:20:30 -04:00
parent 3e0d4df54a
commit 4c7e092cac
4 changed files with 21 additions and 43 deletions
+9 -1
View File
@@ -2,6 +2,14 @@
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/). All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/).
## [0.11.7] - [Unreleased]
### Changed
- Upgrade `pdfminer.six` from `20250327` to `20250506`
### Removed
- Remove `stroking_pattern` and `non_stroking_pattern` object attributes
## [0.11.6] - 2025-03-27 ## [0.11.6] - 2025-03-27
### Changed ### Changed
- Upgrade `pdfminer.six` from `20231228` to `20250327` ([3fcb493](https://github.com/jsvine/pdfplumber/commit/3fcb493) + [12a73a2](https://github.com/jsvine/pdfplumber/commit/12a73a2)) - Upgrade `pdfminer.six` from `20231228` to `20250327` ([3fcb493](https://github.com/jsvine/pdfplumber/commit/3fcb493) + [12a73a2](https://github.com/jsvine/pdfplumber/commit/12a73a2))
@@ -13,7 +21,7 @@ All notable changes to this project will be documented in this file. The format
- Catch exceptions from pdfminer and malformed PDFs ([43ccc5b](https://github.com/jsvine/pdfplumber/commit/43ccc5b)) - Catch exceptions from pdfminer and malformed PDFs ([43ccc5b](https://github.com/jsvine/pdfplumber/commit/43ccc5b))
- More broadly handle RecursionError ([748ff31](https://github.com/jsvine/pdfplumber/commit/748ff31)) - More broadly handle RecursionError ([748ff31](https://github.com/jsvine/pdfplumber/commit/748ff31))
## Removed ### Removed
- Remove test_issue_1089 ([#1263](https://github.com/jsvine/pdfplumber/issues/1263) + [7e28e76](https://github.com/jsvine/pdfplumber/commit/7e28e76)) - Remove test_issue_1089 ([#1263](https://github.com/jsvine/pdfplumber/issues/1263) + [7e28e76](https://github.com/jsvine/pdfplumber/commit/7e28e76))
## [0.11.5] - 2025-01-01 ## [0.11.5] - 2025-01-01
+4 -34
View File
@@ -100,29 +100,6 @@ def fix_fontname_bytes(fontname: bytes) -> str:
return str(prefix)[2:-1] + suffix_new return str(prefix)[2:-1] + suffix_new
def separate_pattern(
color: Tuple[Any, ...]
) -> Tuple[Optional[Tuple[Union[float, int], ...]], Optional[str]]:
if isinstance(color[-1], PSLiteral):
return (color[:-1] or None), decode_text(color[-1].name)
else:
return color, None
def normalize_color(
color: Any,
) -> Tuple[Optional[Tuple[Union[float, int], ...]], Optional[str]]:
if color is None:
return (None, None)
elif isinstance(color, tuple):
tuplefied = color
elif isinstance(color, list):
tuplefied = tuple(color)
else:
tuplefied = (color,)
return separate_pattern(tuplefied)
def tuplify_list_kwargs(kwargs: Dict[str, Any]) -> Dict[str, Any]: def tuplify_list_kwargs(kwargs: Dict[str, Any]) -> Dict[str, Any]:
return { return {
key: (tuple(value) if isinstance(value, list) else value) key: (tuple(value) if isinstance(value, list) else value)
@@ -395,13 +372,6 @@ class Page(Container):
if hasattr(obj, cs): if hasattr(obj, cs):
attr[cs] = resolve_and_decode(getattr(obj, cs).name) attr[cs] = resolve_and_decode(getattr(obj, cs).name)
for color_attr, pattern_attr in [
("stroking_color", "stroking_pattern"),
("non_stroking_color", "non_stroking_pattern"),
]:
if color_attr in attr:
attr[color_attr], attr[pattern_attr] = normalize_color(attr[color_attr])
if isinstance(obj, (LTChar, LTTextContainer)): if isinstance(obj, (LTChar, LTTextContainer)):
text = obj.get_text() text = obj.get_text()
attr["text"] = ( attr["text"] = (
@@ -415,11 +385,11 @@ class Page(Container):
# directly expose .stroking_color and .non_stroking_color # directly expose .stroking_color and .non_stroking_color
# for LTChar objects (unlike, e.g., LTRect objects). # for LTChar objects (unlike, e.g., LTRect objects).
gs = obj.graphicstate gs = obj.graphicstate
attr["stroking_color"], attr["stroking_pattern"] = normalize_color( attr["stroking_color"] = (
gs.scolor gs.scolor if isinstance(gs.scolor, tuple) else (gs.scolor,)
) )
attr["non_stroking_color"], attr["non_stroking_pattern"] = normalize_color( attr["non_stroking_color"] = (
gs.ncolor gs.ncolor if isinstance(gs.ncolor, tuple) else (gs.ncolor,)
) )
# Handle (rare) byte-encoded fontnames # Handle (rare) byte-encoded fontnames
+1 -1
View File
@@ -1,3 +1,3 @@
pdfminer.six==20250327 pdfminer.six==20250506
Pillow>=9.1 Pillow>=9.1
pypdfium2>=4.18.0 pypdfium2>=4.18.0
+7 -7
View File
@@ -177,8 +177,9 @@ class Test(unittest.TestCase):
c = self.pdf.to_csv(precision=3) c = self.pdf.to_csv(precision=3)
assert c.split("\r\n")[9] == ( assert c.split("\r\n")[9] == (
"char,1,45.83,58.826,656.82,674.82,117.18,117.18,135.18,12.996," "char,1,45.83,58.826,656.82,674.82,117.18,117.18,135.18,12.996,"
'18.0,12.996,,,,,,,TimesNewRomanPSMT,,,"(1, 0, 0, 1, 45.83, 660.69)"' "18.0,12.996,,,,,,,TimesNewRomanPSMT,,,"
',,,DeviceRGB,"(0, 0, 0)",,,,18.0,,,,,,,Y,,1,' '"(1.0, 0.0, 0.0, 1.0, 45.83, 660.69)"'
',,,DeviceRGB,"(0.0, 0.0, 0.0)",,,18.0,,,,"(0,)",,Y,,1,'
) )
io = StringIO() io = StringIO()
@@ -244,8 +245,9 @@ class Test(unittest.TestCase):
assert res.decode("utf-8").split("\r\n")[9] == ( assert res.decode("utf-8").split("\r\n")[9] == (
"char,1,45.83,58.826,656.82,674.82,117.18,117.18,135.18,12.996," "char,1,45.83,58.826,656.82,674.82,117.18,117.18,135.18,12.996,"
'18.0,12.996,,,,,,,TimesNewRomanPSMT,,,"(1, 0, 0, 1, 45.83, 660.69)"' "18.0,12.996,,,,,,,TimesNewRomanPSMT,,,"
',,,DeviceRGB,"(0, 0, 0)",,,,18.0,,,,,,,Y,,1,' '"(1.0, 0.0, 0.0, 1.0, 45.83, 660.69)"'
',,,DeviceRGB,"(0.0, 0.0, 0.0)",,,18.0,,,,"(0,)",,Y,,1,'
) )
def test_cli_csv_exclude(self): def test_cli_csv_exclude(self):
@@ -263,15 +265,13 @@ class Test(unittest.TestCase):
"matrix", "matrix",
"mcid", "mcid",
"ncs", "ncs",
"non_stroking_pattern",
"stroking_pattern",
] ]
) )
assert res.decode("utf-8").split("\r\n")[9] == ( assert res.decode("utf-8").split("\r\n")[9] == (
"char,1,45.83,58.826,656.82,674.82,117.18,117.18,135.18,12.996," "char,1,45.83,58.826,656.82,674.82,117.18,117.18,135.18,12.996,"
"18.0,12.996,,,,,,,TimesNewRomanPSMT," "18.0,12.996,,,,,,,TimesNewRomanPSMT,"
',,,"(0, 0, 0)",,,18.0,,,,,,Y,,1,' ',,,"(0.0, 0.0, 0.0)",,,18.0,,,,"(0,)",,Y,,1,'
) )
def test_cli_csv_include(self): def test_cli_csv_include(self):