ebook-convert pdf plugin does not render dasharray

Bug #1821923 reported by jimbojw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

Version: 3.21
Platform: Ubuntu

Problem: Attempting to convert an epub to PDF using ebook-convert. The epub file contains inline SVG with <line> elements that have a stroke-dasharray attribute. The example SVG on MDN's stroke-dasharray page exhibits the problem[1].

Root cause: in calibre/ebooks/pdf/render/graphics.py, in the apply_stroke() method, in the section on applying the dash pattern, the code checks pen.style() against a list of several Qt::PenStyle enum values[2]. However, the actual pen.style() value for an SVG element with a dasharray attribute is Qt.CustomDashLine, which is not in the checked list.

Solution: Add a check for Qt.CustomDashLine and if present, use the pen.dashPattern() and pen.dashOffset() values for the dashArray and dashPhase parameters to the 'd' operator respectively.

Caveat: Once you make this change, you'll also need to make sure to reset the dash style for the next path. I've found that always setting the dash style solves this problem.

[1] https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
[2] https://doc.qt.io/archives/qt-4.8/qt.html#PenStyle-enum

Tags: pdf-output
Revision history for this message
jimbojw (jimbojw) wrote :

Created PR 951 to fix this issue. https://github.com/kovidgoyal/calibre/pull/951

Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.