dont fail parsing parts of the pdf

This commit is contained in:
j 2016-01-25 15:51:54 +05:30
parent bfa29b469d
commit c03f72b47c

View file

@ -131,7 +131,10 @@ def info(pdf):
toc = parse_tableofcontents(pdfreader) toc = parse_tableofcontents(pdfreader)
if toc: if toc:
data['tableofcontents'] = toc data['tableofcontents'] = toc
try:
info = pdfreader.getDocumentInfo() info = pdfreader.getDocumentInfo()
except:
info = None
if info: if info:
for key in info: for key in info:
if info[key]: if info[key]:
@ -144,8 +147,10 @@ def info(pdf):
data[key[1:].lower()] = value data[key[1:].lower()] = value
except: except:
pass pass
try:
xmp = pdfreader.getXmpMetadata() xmp = pdfreader.getXmpMetadata()
except:
xmp = None
if xmp: if xmp:
for key in dir(xmp): for key in dir(xmp):
if key.startswith('dc_'): if key.startswith('dc_'):