too many ids in input causes zoomed out converted pdf
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
calibre |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
calibre version 4.4 (git head at 8db03fd0c8 using CALIBRE_
OS: ubuntu
Scenario: using ebook-convert to convert an HTML or epub document to PDF.
Problem: When there are too many id attributes on elements in the input epub or HTML file, the rendered PDF appears 'zoomed out'. The most obvious effect of this is that the font size appears to be smaller than intended, but other elements are reduced as well.
The example files attached demonstrate the problem. Each file has 100 paragraphs of content. The only difference between working.html and broken.html is that the latter has an id attribute on each paragraph element.
Commands:
ebook-convert working.html working.pdf --pdf-default-
ebook-convert broken.html broken.pdf --pdf-default-
Additional context: Changing the types of elements that have the ids does not make a difference. I discovered this problem initially because of id attributes on list-item elements (<li>) but it happens on every kind of element that I've tried. I also tried switching to anchor tags (<a>) and using the deprecated 'name' attribute instead, but that exhibits the same problem.
I tried force the body of the document to have a fixed width in CSS, but this did not stop the problem from happening. While capping the width of elements does stop them from growing, the width is scaled by the zoom factor of the bug.
The effect seems to be progressive within certain bounds. For example, if there are a small number of elements with ids, then the problem does not occur. As you add more ids, after some threshold (not exactly sure how many) the problem starts to manifest. The zoom factor gets incrementally worse as you add more ids up to a point. After some second threshold, additional elements with ids do not seem to make the zoom factor any worse.
In the example input files, I've added a 1em border around the paragraph elements to show that that is also affected by the scale effect, not just the literal font size of the text.