mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
PDF Output: Ignore invalid links instead of erroring out on them. Fixes #1179314 (conversion from CHM to PDF fails)
This commit is contained in:
parent
1c225cac66
commit
cc223574d0
@ -45,11 +45,15 @@ class Links(object):
|
||||
href, page, rect = link
|
||||
p, frag = href.partition('#')[0::2]
|
||||
try:
|
||||
link = ((path, p, frag or None), self.pdf.get_pageref(page).obj, Array(rect))
|
||||
pref = self.pdf.get_pageref(page).obj
|
||||
except IndexError:
|
||||
self.log.warn('Unable to find page for link: %r, ignoring it' % link)
|
||||
continue
|
||||
self.links.append(link)
|
||||
try:
|
||||
pref = self.pdf.get_pageref(page-1).obj
|
||||
except IndexError:
|
||||
self.pdf.debug('Unable to find page for link: %r, ignoring it' % link)
|
||||
continue
|
||||
self.pdf.debug('The link %s points to non-existent page, moving it one page back' % href)
|
||||
self.links.append(((path, p, frag or None), pref, Array(rect)))
|
||||
|
||||
def add_links(self):
|
||||
for link in self.links:
|
||||
|
Loading…
x
Reference in New Issue
Block a user