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:
Kovid Goyal 2019-11-28 17:38:13 +05:30
parent 163b2dfd2d
commit 08efb46599
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -13,7 +13,7 @@ import signal
import sys
from collections import namedtuple
from io import BytesIO
from itertools import repeat
from itertools import count, repeat
from operator import attrgetter, itemgetter
from html5_parser import parse
@ -422,14 +422,21 @@ def add_anchors_markup(root, uuid, anchors):
)
div.text = '\n\n'
body.append(div)
c = count()
def a(anchor):
num = next(c)
a = div.makeelement(
XHTML('a'), href='#' + anchor,
style='min-width: 10px !important; min-height: 10px !important; border: solid 1px !important;'
)
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)
a.count = 0
tuple(map(a, anchors))
a(uuid)