Skip to content

Commit

Permalink
Add name property to image objects (#1201)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvine committed Oct 3, 2024
1 parent e921ea7 commit 6ef62c9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

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.5] - 2024-10-02

### Added

- Add `name` property to `image` objects (h/t @djr2015). ([#1201](https://github.com/jsvine/pdfplumber/discussions/1201))


## [0.11.4] - 2024-08-18

### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ Additionally, both `pdfplumber.PDF` and `pdfplumber.Page` provide access to seve
|`bits`| The number of bits per color component; e.g., 8 corresponds to 255 possible values for each color component (R, G, and B in an RGB color space).|
|`stream`| Pixel values of the image, as a `pdfminer.pdftypes.PDFStream` object.|
|`imagemask`| A nullable boolean; if `True`, "specifies that the image data is to be used as a stencil mask for painting in the current color."|
|`name`| "The name by which this image XObject is referenced in the XObject subdictionary of the current resource dictionary." [🔗](https://ghostscript.com/~robin/pdf_reference17.pdf#page=340) |
|`mcid`| The [marked content](https://ghostscript.com/~robin/pdf_reference17.pdf#page=850) section ID for this image if any (otherwise `None`). *Experimental attribute.*|
|`tag`| The [marked content](https://ghostscript.com/~robin/pdf_reference17.pdf#page=850) section tag for this image if any (otherwise `None`). *Experimental attribute.*|
|`object_type`| "image"|
Expand Down
1 change: 1 addition & 0 deletions pdfplumber/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"stroke",
"stroking_color",
"stream",
"name",
"mcid",
"tag",
]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_csv(self):
assert c.split("\r\n")[9] == (
"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)"'
',,DeviceRGB,"(0, 0, 0)",,,,18.0,,,,,,,Y,,1,'
',,,DeviceRGB,"(0, 0, 0)",,,,18.0,,,,,,,Y,,1,'
)

io = StringIO()
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_cli_csv(self):
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,"
'18.0,12.996,,,,,,,TimesNewRomanPSMT,,,"(1, 0, 0, 1, 45.83, 660.69)"'
',,DeviceRGB,"(0, 0, 0)",,,,18.0,,,,,,,Y,,1,'
',,,DeviceRGB,"(0, 0, 0)",,,,18.0,,,,,,,Y,,1,'
)

def test_cli_csv_exclude(self):
Expand All @@ -271,7 +271,7 @@ def test_cli_csv_exclude(self):
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,"
"18.0,12.996,,,,,,,TimesNewRomanPSMT,"
',,"(0, 0, 0)",,,18.0,,,,,,Y,,1,'
',,,"(0, 0, 0)",,,18.0,,,,,,Y,,1,'
)

def test_cli_csv_include(self):
Expand Down

0 comments on commit 6ef62c9

Please sign in to comment.