Skip to content

Commit

Permalink
Merge branch 'idan-david/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvine committed Jul 18, 2020
2 parents 0731d60 + 334a49b commit 0254da3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pdfplumber/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ def process_object(obj):
attr["object_type"] = kind
attr["page_number"] = pno

if hasattr(obj, "graphicstate"):
gs = obj.graphicstate
attr['stroking_color'] = gs.scolor
attr['non_stroking_color'] = gs.ncolor

if hasattr(obj, "get_text"):
attr["text"] = obj.get_text()

Expand Down
6 changes: 6 additions & 0 deletions tests/test-basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ def test_colors(self):
rect = pdf.pages[0].rects[0]
assert rect['non_stroking_color'] == [0.8, 1, 1]

def test_text_colors(self):
path = os.path.join(HERE, "pdfs/nics-background-checks-2015-11.pdf")
with pdfplumber.open(path) as pdf:
char = pdf.pages[0].chars[3358]
assert char['non_stroking_color'] == [1, 0, 0]

def test_load_with_custom_laparams(self):
# See https://github.com/jsvine/pdfplumber/issues/168
path = os.path.join(HERE, "pdfs/cupertino_usd_4-6-16.pdf")
Expand Down

0 comments on commit 0254da3

Please sign in to comment.