Skip to content

Commit

Permalink
Fix resolution/decoding of list-type metadata
Browse files Browse the repository at this point in the history
Big thanks to @jeffbarrera for flagging:
jsvine#14
  • Loading branch information
jsvine committed May 24, 2016
1 parent bb49ac8 commit 302b8a7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pdfplumber/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pdfminer.pdftypes.STRICT = False
pdfminer.pdfinterp.STRICT = False

VERSION_TUPLE = (0, 4, 3)
VERSION_TUPLE = (0, 4, 4)
VERSION = ".".join(map(str, VERSION_TUPLE))

def load(file_or_buffer, **kwargs):
Expand Down
5 changes: 4 additions & 1 deletion pdfplumber/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def __init__(self, stream, pages=None, laparams=None, precision=0.001):
for k, v in self.metadata.items():
if hasattr(v, "resolve"):
v = v.resolve()
self.metadata[k] = decode_text(v)
if type(v) == list:
self.metadata[k] = list(map(decode_text, v))
else:
self.metadata[k] = decode_text(v)
self.device = PDFPageAggregator(rsrcmgr, laparams=self.laparams)
self.interpreter = PDFPageInterpreter(rsrcmgr, self.device)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages
import subprocess

version = "0.4.3"
version = "0.4.4"

base_reqs = [
"chardet",
Expand Down
Binary file added tests/pdfs/cupertino_usd_4-6-16.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/test-list-metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import unittest
import pdfplumber
import sys, os

import logging
logging.disable(logging.ERROR)

HERE = os.path.abspath(os.path.dirname(__file__))

class Test(unittest.TestCase):

def test_load(self):
path = os.path.join(HERE, "pdfs/cupertino_usd_4-6-16.pdf")
pdf = pdfplumber.from_path(path)

0 comments on commit 302b8a7

Please sign in to comment.