From 7720a696d8dc47128ff94143a4bff6e9cf5034b1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 6 Jan 2013 01:14:36 +0530 Subject: [PATCH] PDF Output: Do not error out when the input document contains links with anchors not present in the document. Fixes #1096428 (pdf conversion fails in 0.9.13 64 bit calibre) --- src/calibre/ebooks/pdf/render/links.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdf/render/links.py b/src/calibre/ebooks/pdf/render/links.py index 41b7fcfd39..188dbd4494 100644 --- a/src/calibre/ebooks/pdf/render/links.py +++ b/src/calibre/ebooks/pdf/render/links.py @@ -58,7 +58,13 @@ class Links(object): 0])}) if is_local: path = combined_path if href else path - annot['Dest'] = self.anchors[path][frag] + try: + annot['Dest'] = self.anchors[path][frag] + except KeyError: + try: + annot['Dest'] = self.anchors[path][None] + except KeyError: + pass else: url = href + (('#'+frag) if frag else '') purl = urlparse(url)