getobj can raise PDFObjectNotFound

This commit is contained in:
vi 2013-12-07 07:20:13 +08:00
parent 95a249d8ab
commit e95374ec04
1 changed files with 40 additions and 35 deletions

View File

@ -10,6 +10,8 @@ from ..eraser import (
)
from ..plugin import Plugin
from pdfminer.pdftypes import PDFObjectNotFound
class JSTOR(Plugin):
"""
JSTOR
@ -50,6 +52,7 @@ class JSTOR(Plugin):
# check each object in the pdf
for objid in objids:
# get an object by id
try:
obj = pdf.getobj(objid)
if hasattr(obj, "attrs"):
@ -92,6 +95,8 @@ class JSTOR(Plugin):
replacements.append([objid, better_content])
page_id += 1
except PDFObjectNotFound, e:
print >>sys.stderr, 'Missing object: %r' % e
if verbose >= 1 and replacements:
sys.stderr.write("%s: Found objects %s with %r; omitting..." % (cls.__name__, [deets[0] for deets in replacements], cls.requirements))