diff --git a/pdfminer/pdfdocument.py b/pdfminer/pdfdocument.py index a63213a..4817d80 100644 --- a/pdfminer/pdfdocument.py +++ b/pdfminer/pdfdocument.py @@ -294,7 +294,7 @@ class PDFStandardSecurityHandler(object): b'..\x00\xb6\xd0h>\x80/\x0c\xa9\xfedSiz') supported_revisions = (2, 3) - def __init__(self, docid, param, password=b''): + def __init__(self, docid, param, password=''): self.docid = docid self.param = param self.password = password @@ -366,6 +366,7 @@ class PDFStandardSecurityHandler(object): return result[:n] def authenticate(self, password): + password = password.encode("latin1") key = self.authenticate_user_password(password) if key is None: key = self.authenticate_owner_password(password) @@ -536,7 +537,7 @@ class PDFDocument(object): if SHA256 is not None: security_handler_registry[5] = PDFStandardSecurityHandlerV5 - def __init__(self, parser, password=b'', caching=True, fallback=True): + def __init__(self, parser, password='', caching=True, fallback=True): "Set the document to use a given PDFParser object." self.caching = caching self.xrefs = [] @@ -587,7 +588,7 @@ class PDFDocument(object): # _initialize_password(password=b'') # Perform the initialization with a given password. - def _initialize_password(self, password=b''): + def _initialize_password(self, password=''): (docid, param) = self.encryption if literal_name(param.get('Filter')) != 'Standard': raise PDFEncryptionError('Unknown filter: param=%r' % param) diff --git a/pdfminer/pdfpage.py b/pdfminer/pdfpage.py index 25a351c..41882ea 100644 --- a/pdfminer/pdfpage.py +++ b/pdfminer/pdfpage.py @@ -113,7 +113,7 @@ class PDFPage(object): @classmethod def get_pages(klass, fp, - pagenos=None, maxpages=0, password=b'', + pagenos=None, maxpages=0, password='', caching=True, check_extractable=True): # Create a PDF parser object associated with the file object. parser = PDFParser(fp) diff --git a/tools/dumppdf.py b/tools/dumppdf.py index 860da56..954b520 100755 --- a/tools/dumppdf.py +++ b/tools/dumppdf.py @@ -241,7 +241,7 @@ def main(argv): objids = [] pagenos = set() codec = None - password = b'' + password = '' dumpall = False proc = dumppdf outfp = sys.stdout diff --git a/tools/pdf2txt.py b/tools/pdf2txt.py index 40711d4..fb12686 100755 --- a/tools/pdf2txt.py +++ b/tools/pdf2txt.py @@ -27,7 +27,7 @@ def main(argv): return usage() if not args: return usage() # input option - password = b'' + password = '' pagenos = set() maxpages = 0 # output option