diff --git a/PyPDF2/filters.py b/PyPDF2/filters.py index bb56234a7..c479f9bec 100644 --- a/PyPDF2/filters.py +++ b/PyPDF2/filters.py @@ -54,7 +54,17 @@ import zlib def decompress(data): - return zlib.decompress(data) + try: + return zlib.decompress(data) + except zlib.error: + d = zlib.decompressobj(zlib.MAX_WBITS | 32) + result_str = b'' + for b in [data[i:i + 1] for i in range(len(data))]: + try: + result_str += d.decompress(b) + except zlib.error: + pass + return result_str def compress(data): return zlib.compress(data)