From 2e58ce28f68d56895c28b90c55c281aa32474d13 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 5 Dec 2008 11:43:46 -0800 Subject: [PATCH] Fix #1329 (There is a blank page before the book cover) --- src/calibre/ebooks/lrf/html/convert_from.py | 4 ++++ src/calibre/ebooks/lrf/pylrs/pylrs.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index f219b92c67..c9ae5e8c58 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -520,6 +520,8 @@ class HTMLConverter(object, LoggingInterface): self.book.append(self.current_page) self.current_page = None + if top not in top.parent.contents: # May have been removed for a cover image + top = top.parent.contents[0] if not top.has_text() and top.parent.contents.index(top) == len(top.parent.contents)-1: # Empty block at the bottom of a page opage = top.parent @@ -1028,6 +1030,8 @@ class HTMLConverter(object, LoggingInterface): self.current_para = Paragraph() else: self.end_page() + if len(self.current_page.contents) == 1 and not self.current_page.has_text(): + self.current_page.contents[0:1] = [] self.current_page.append(Canvas(width=pwidth, height=height)) left = int(floor((pwidth - width)/2.)) diff --git a/src/calibre/ebooks/lrf/pylrs/pylrs.py b/src/calibre/ebooks/lrf/pylrs/pylrs.py index 6ee440ce66..60f8d21336 100644 --- a/src/calibre/ebooks/lrf/pylrs/pylrs.py +++ b/src/calibre/ebooks/lrf/pylrs/pylrs.py @@ -2338,6 +2338,9 @@ class Canvas(LrsObject, LrsContainer, LrsAttributes): container.addLrfObject(c.objId) lrfWriter.append(c) + def has_text(self): + return bool(self.contents) + class PutObj(LrsContainer):