Speed up handling of PDFs with large images with more minimal change

pull/133/head
Tim Bell 2018-04-03 07:21:09 +10:00
parent fab1c9462c
commit 185ddeb2ab
1 changed files with 3 additions and 4 deletions

View File

@ -102,7 +102,7 @@ class PDFParser(PSStackParser):
return
pos += len(line)
self.fp.seek(pos)
data_list = [self.fp.read(objlen)]
data = bytearray(self.fp.read(objlen))
self.seek(pos+objlen)
while 1:
try:
@ -115,12 +115,11 @@ class PDFParser(PSStackParser):
i = line.index(b'endstream')
objlen += i
if self.fallback:
data_list.append(line[:i])
data += line[:i]
break
objlen += len(line)
if self.fallback:
data_list.append(line)
data = b''.join(data_list)
data += line
self.seek(pos+objlen)
# XXX limit objlen not to exceed object boundary
log.debug('Stream: pos=%d, objlen=%d, dic=%r, data=%r...', pos, objlen, dic, data[:10])