PDF Output: Ignore links whose page refs cannot be found, instead of erroring out

This commit is contained in:
Kovid Goyal 2013-04-30 18:10:50 +05:30
parent 890b5e4c57
commit b3af0799f9

View File

@ -44,7 +44,11 @@ class Links(object):
for link in links:
href, page, rect = link
p, frag = href.partition('#')[0::2]
link = ((path, p, frag or None), self.pdf.get_pageref(page).obj, Array(rect))
try:
link = ((path, p, frag or None), self.pdf.get_pageref(page).obj, Array(rect))
except IndexError:
self.log.warn('Unable to find page for link: %r, ignoring it' % link)
continue
self.links.append(link)
def add_links(self):