mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
PDF Output: Fix incorrect rendering if the input document has too many anchors. Fixes #1854345 [too many ids in input causes zoomed out converted pdf](https://bugs.launchpad.net/calibre/+bug/1854345)
This commit is contained in:
parent
163b2dfd2d
commit
08efb46599
@ -13,7 +13,7 @@ import signal
|
|||||||
import sys
|
import sys
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from itertools import repeat
|
from itertools import count, repeat
|
||||||
from operator import attrgetter, itemgetter
|
from operator import attrgetter, itemgetter
|
||||||
|
|
||||||
from html5_parser import parse
|
from html5_parser import parse
|
||||||
@ -422,14 +422,21 @@ def add_anchors_markup(root, uuid, anchors):
|
|||||||
)
|
)
|
||||||
div.text = '\n\n'
|
div.text = '\n\n'
|
||||||
body.append(div)
|
body.append(div)
|
||||||
|
c = count()
|
||||||
|
|
||||||
def a(anchor):
|
def a(anchor):
|
||||||
|
num = next(c)
|
||||||
a = div.makeelement(
|
a = div.makeelement(
|
||||||
XHTML('a'), href='#' + anchor,
|
XHTML('a'), href='#' + anchor,
|
||||||
style='min-width: 10px !important; min-height: 10px !important; border: solid 1px !important;'
|
style='min-width: 10px !important; min-height: 10px !important; border: solid 1px !important;'
|
||||||
)
|
)
|
||||||
a.text = a.tail = ' '
|
a.text = a.tail = ' '
|
||||||
|
if num % 8 == 0:
|
||||||
|
# prevent too many anchors on a line as it causes chromium to
|
||||||
|
# rescale the viewport
|
||||||
|
a.tail = '\n'
|
||||||
div.append(a)
|
div.append(a)
|
||||||
|
a.count = 0
|
||||||
tuple(map(a, anchors))
|
tuple(map(a, anchors))
|
||||||
a(uuid)
|
a(uuid)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user