From 21f6cf8fb65ba990cc3c78b41a6193db26b3b95b Mon Sep 17 00:00:00 2001 From: "yusuke.shinyama.dummy" Date: Sun, 17 Oct 2010 05:15:18 +0000 Subject: [PATCH] removed PDFStream.decomp(). turned out zlib can handle trailing bytes. git-svn-id: https://pdfminerr.googlecode.com/svn/trunk/pdfminer@253 1aa58f4a-7d42-0410-adbc-911cccaed67c --- pdfminer/pdftypes.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/pdfminer/pdftypes.py b/pdfminer/pdftypes.py index 64714c4..a6b267b 100644 --- a/pdfminer/pdftypes.py +++ b/pdfminer/pdftypes.py @@ -193,19 +193,6 @@ class PDFStream(PDFObject): if isinstance(filters, list): return filters return [ filters ] - def decomp(self,data): - buf = data - # some FlateDecode streams have garbage (newlines, etc) appended to the - # end. remove chars from the end to try and decompress the buffer - while 8 <= len(buf): - try: - # will get errors if the document is encrypted. - dco = zlib.decompressobj() - return dco.decompress(buf) - except zlib.error: - buf = buf[:-1] - raise Exception, "zlib.error while decompressing data" - def decode(self): assert self.data is None and self.rawdata != None data = self.rawdata @@ -220,7 +207,10 @@ class PDFStream(PDFObject): for f in filters: if f in LITERALS_FLATE_DECODE: # will get errors if the document is encrypted. - data = self.decomp(data) + try: + data = zlib.decompress(data) + except zlib.error: + data = '' elif f in LITERALS_LZW_DECODE: data = lzwdecode(data) elif f in LITERALS_ASCII85_DECODE: