PDF: Ignore invalid objid in non-strict mode, fixes #233
This commit is contained in:
parent
a30405bebf
commit
a711954323
|
@ -1831,7 +1831,19 @@ class PDFDocument(object):
|
||||||
try:
|
try:
|
||||||
obj = objs[i]
|
obj = objs[i]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
# This IndexError used to just raise an exception.
|
||||||
|
# Unfortunately that seems to break some PDFs, see this issue:
|
||||||
|
# https://github.com/noDRM/DeDRM_tools/issues/233
|
||||||
|
# I'm not sure why this is the case, but lets try only raising that exception
|
||||||
|
# when in STRICT mode, and make it a warning otherwise.
|
||||||
|
if STRICT:
|
||||||
raise PDFSyntaxError('Invalid object number: objid=%r' % (objid))
|
raise PDFSyntaxError('Invalid object number: objid=%r' % (objid))
|
||||||
|
|
||||||
|
print('Invalid object number: objid=%r' % (objid))
|
||||||
|
print("Continuing anyways?")
|
||||||
|
print("If the resulting PDF is corrupted, please open a bug report.")
|
||||||
|
return None
|
||||||
|
|
||||||
if isinstance(obj, PDFStream):
|
if isinstance(obj, PDFStream):
|
||||||
obj.set_objid(objid, 0)
|
obj.set_objid(objid, 0)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue