From 4c036eeeddbc00d1e43921fc5518c51be8176e15 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Feb 2014 08:20:57 +0530 Subject: [PATCH] PDF Output: Fix a zero division error when the transformation matrix has a zero diagonal --- src/calibre/ebooks/pdf/render/graphics.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/pdf/render/graphics.py b/src/calibre/ebooks/pdf/render/graphics.py index 51e2f8c407..760feece86 100644 --- a/src/calibre/ebooks/pdf/render/graphics.py +++ b/src/calibre/ebooks/pdf/render/graphics.py @@ -407,7 +407,10 @@ class Graphics(object): w = pen.widthF() if pen.isCosmetic(): t = painter.transform() - w /= sqrt(t.m11()**2 + t.m22()**2) + try: + w /= sqrt(t.m11()**2 + t.m22()**2) + except ZeroDivisionError: + w = 0 pdf.serialize(w) pdf.current_page.write(' w ')