Merge pull request #261 from speedplane/feature/readInlineImageEIQFeature-1

Fix a bug in _readInlineImage
This commit is contained in:
Matthew Stamy 2016-05-15 16:06:41 -05:00
commit 78fd8c602f
2 changed files with 11 additions and 4 deletions

View File

@ -234,8 +234,12 @@ class FloatObject(decimal.Decimal, PdfObject):
if self == self.to_integral():
return str(self.quantize(decimal.Decimal(1)))
else:
# XXX: this adds useless extraneous zeros.
return "%.5f" % self
# Standard formatting adds useless extraneous zeros.
o = "%.5f" % self
# Remove the zeros.
while o and o[-1] == '0':
o = o[:-1]
return o
def as_numeric(self):
return float(b_(repr(self)))

View File

@ -2731,13 +2731,16 @@ class ContentStream(DecodedStreamObject):
# Check for End Image
tok2 = stream.read(1)
if tok2 == b_("I"):
# Sometimes that data will contain EI, so check for the Q operator.
# Data can contain EI, so check for the Q operator.
tok3 = stream.read(1)
info = tok + tok2
# We need to find whitespace between EI and Q.
has_q_whitespace = False
while tok3 in utils.WHITESPACES:
has_q_whitespace = True
info += tok3
tok3 = stream.read(1)
if tok3 == b_("Q"):
if tok3 == b_("Q") and has_q_whitespace:
stream.seek(-1, 1)
break
else: