Skip to content

Commit 78fd8c6

Browse files
committed
Merge pull request #261 from speedplane/feature/readInlineImageEIQFeature-1
Fix a bug in _readInlineImage
2 parents fcd0ac0 + 9dadb45 commit 78fd8c6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

PyPDF2/generic.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,12 @@ def __repr__(self):
234234
if self == self.to_integral():
235235
return str(self.quantize(decimal.Decimal(1)))
236236
else:
237-
# XXX: this adds useless extraneous zeros.
238-
return "%.5f" % self
237+
# Standard formatting adds useless extraneous zeros.
238+
o = "%.5f" % self
239+
# Remove the zeros.
240+
while o and o[-1] == '0':
241+
o = o[:-1]
242+
return o
239243

240244
def as_numeric(self):
241245
return float(b_(repr(self)))

PyPDF2/pdf.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2731,13 +2731,16 @@ def _readInlineImage(self, stream):
27312731
# Check for End Image
27322732
tok2 = stream.read(1)
27332733
if tok2 == b_("I"):
2734-
# Sometimes that data will contain EI, so check for the Q operator.
2734+
# Data can contain EI, so check for the Q operator.
27352735
tok3 = stream.read(1)
27362736
info = tok + tok2
2737+
# We need to find whitespace between EI and Q.
2738+
has_q_whitespace = False
27372739
while tok3 in utils.WHITESPACES:
2740+
has_q_whitespace = True
27382741
info += tok3
27392742
tok3 = stream.read(1)
2740-
if tok3 == b_("Q"):
2743+
if tok3 == b_("Q") and has_q_whitespace:
27412744
stream.seek(-1, 1)
27422745
break
27432746
else:

0 commit comments

Comments
 (0)