PDF Output: Fix a regression in the previous release that broke conversion to PDF for some files. Fixes #1689192 [Private bug](https://bugs.launchpad.net/calibre/+bug/1689192)

This commit is contained in:
Kovid Goyal 2017-05-08 09:34:31 +05:30
parent 5a5406b5d5
commit acba68e240
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 8 deletions

View File

@ -351,15 +351,15 @@ class PDFWriter(QObject):
evaljs(self.paged_js)
self.load_mathjax()
amap = evaljs('''
amap = json.loads(evaljs('''
document.body.style.backgroundColor = "white";
paged_display.set_geometry(1, %d, %d, %d);
paged_display.layout();
paged_display.fit_images();
ret = book_indexing.all_links_and_anchors();
window.scrollTo(0, 0); // This is needed as getting anchor positions could have caused the viewport to scroll
ret;
'''%(self.margin_top, 0, self.margin_bottom))
JSON.stringify(ret);
'''%(self.margin_top, 0, self.margin_bottom)))
if not isinstance(amap, dict):
amap = {'links':[], 'anchors':{}} # Some javascript error occurred

View File

@ -247,10 +247,10 @@ class Document(QWebPage): # {{{
self.first_load = False
def colors(self):
ans = self.javascript('''
ans = json.loads(self.javascript('''
bs = getComputedStyle(document.body);
[bs.backgroundColor, bs.color]
''')
JSON.stringify([bs.backgroundColor, bs.color])
'''))
return ans if isinstance(ans, list) else ['white', 'black']
def read_anchor_positions(self, use_cache=True):
@ -299,8 +299,8 @@ class Document(QWebPage): # {{{
def column_boundaries(self):
if not self.loaded_javascript:
return (0, 1)
ans = self.javascript(u'paged_display.column_boundaries()')
return tuple(int(x) for x in ans)
ans = self.javascript(u'JSON.stringify(paged_display.column_boundaries())')
return tuple(int(x) for x in json.loads(ans))
def after_resize(self):
if self.in_paged_mode: