mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
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:
parent
5a5406b5d5
commit
acba68e240
@ -351,15 +351,15 @@ class PDFWriter(QObject):
|
|||||||
evaljs(self.paged_js)
|
evaljs(self.paged_js)
|
||||||
self.load_mathjax()
|
self.load_mathjax()
|
||||||
|
|
||||||
amap = evaljs('''
|
amap = json.loads(evaljs('''
|
||||||
document.body.style.backgroundColor = "white";
|
document.body.style.backgroundColor = "white";
|
||||||
paged_display.set_geometry(1, %d, %d, %d);
|
paged_display.set_geometry(1, %d, %d, %d);
|
||||||
paged_display.layout();
|
paged_display.layout();
|
||||||
paged_display.fit_images();
|
paged_display.fit_images();
|
||||||
ret = book_indexing.all_links_and_anchors();
|
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
|
window.scrollTo(0, 0); // This is needed as getting anchor positions could have caused the viewport to scroll
|
||||||
ret;
|
JSON.stringify(ret);
|
||||||
'''%(self.margin_top, 0, self.margin_bottom))
|
'''%(self.margin_top, 0, self.margin_bottom)))
|
||||||
|
|
||||||
if not isinstance(amap, dict):
|
if not isinstance(amap, dict):
|
||||||
amap = {'links':[], 'anchors':{}} # Some javascript error occurred
|
amap = {'links':[], 'anchors':{}} # Some javascript error occurred
|
||||||
|
@ -247,10 +247,10 @@ class Document(QWebPage): # {{{
|
|||||||
self.first_load = False
|
self.first_load = False
|
||||||
|
|
||||||
def colors(self):
|
def colors(self):
|
||||||
ans = self.javascript('''
|
ans = json.loads(self.javascript('''
|
||||||
bs = getComputedStyle(document.body);
|
bs = getComputedStyle(document.body);
|
||||||
[bs.backgroundColor, bs.color]
|
JSON.stringify([bs.backgroundColor, bs.color])
|
||||||
''')
|
'''))
|
||||||
return ans if isinstance(ans, list) else ['white', 'black']
|
return ans if isinstance(ans, list) else ['white', 'black']
|
||||||
|
|
||||||
def read_anchor_positions(self, use_cache=True):
|
def read_anchor_positions(self, use_cache=True):
|
||||||
@ -299,8 +299,8 @@ class Document(QWebPage): # {{{
|
|||||||
def column_boundaries(self):
|
def column_boundaries(self):
|
||||||
if not self.loaded_javascript:
|
if not self.loaded_javascript:
|
||||||
return (0, 1)
|
return (0, 1)
|
||||||
ans = self.javascript(u'paged_display.column_boundaries()')
|
ans = self.javascript(u'JSON.stringify(paged_display.column_boundaries())')
|
||||||
return tuple(int(x) for x in ans)
|
return tuple(int(x) for x in json.loads(ans))
|
||||||
|
|
||||||
def after_resize(self):
|
def after_resize(self):
|
||||||
if self.in_paged_mode:
|
if self.in_paged_mode:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user