dont fail parsing parts of the pdf
This commit is contained in:
parent
bfa29b469d
commit
c03f72b47c
1 changed files with 8 additions and 3 deletions
|
@ -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_'):
|
||||||
|
|
Loading…
Reference in a new issue