Fix #1329 (There is a blank page before the book cover)

This commit is contained in:
Kovid Goyal 2008-12-05 11:43:46 -08:00
parent d46c6ca1de
commit 2e58ce28f6
2 changed files with 7 additions and 0 deletions

View File

@ -520,6 +520,8 @@ class HTMLConverter(object, LoggingInterface):
self.book.append(self.current_page) self.book.append(self.current_page)
self.current_page = None 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: if not top.has_text() and top.parent.contents.index(top) == len(top.parent.contents)-1:
# Empty block at the bottom of a page # Empty block at the bottom of a page
opage = top.parent opage = top.parent
@ -1028,6 +1030,8 @@ class HTMLConverter(object, LoggingInterface):
self.current_para = Paragraph() self.current_para = Paragraph()
else: else:
self.end_page() 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, self.current_page.append(Canvas(width=pwidth,
height=height)) height=height))
left = int(floor((pwidth - width)/2.)) left = int(floor((pwidth - width)/2.))

View File

@ -2338,6 +2338,9 @@ class Canvas(LrsObject, LrsContainer, LrsAttributes):
container.addLrfObject(c.objId) container.addLrfObject(c.objId)
lrfWriter.append(c) lrfWriter.append(c)
def has_text(self):
return bool(self.contents)
class PutObj(LrsContainer): class PutObj(LrsContainer):