pdf annot: guard against possible exception while formatting results

This commit is contained in:
Jean-Francois Dockes 2020-10-10 12:48:18 +02:00
parent 1ac589b890
commit 694d0f155d

View File

@ -427,6 +427,8 @@ class PDFExtractor:
for annot_mapping in annot_mappings: for annot_mapping in annot_mappings:
atype = annot_mapping.annot.get_annot_type().value_name atype = annot_mapping.annot.get_annot_type().value_name
if atype != 'POPPLER_ANNOT_LINK': if atype != 'POPPLER_ANNOT_LINK':
# Catch because we sometimes get None values
try:
atext = f.format( atext = f.format(
pnum, pnum,
annot_mapping.annot.get_modified(), annot_mapping.annot.get_modified(),
@ -436,6 +438,8 @@ class PDFExtractor:
abypage[pnum] += atext abypage[pnum] += atext
else: else:
abypage[pnum] = atext abypage[pnum] = atext
except:
pass
#self.em.rclog("Annotations: %s" % abypage) #self.em.rclog("Annotations: %s" % abypage)
pagevec = html.split(b"\f") pagevec = html.split(b"\f")
html = b"" html = b""