1
0
Fork 0
mirror of https://github.com/kanzure/pdfparanoia.git synced 2025-07-03 03:47:25 +02:00

getobj can raise PDFObjectNotFound

This commit is contained in:
vi 2013-12-07 07:20:13 +08:00
parent 95a249d8ab
commit e95374ec04

View file

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