EPUB metadata: When rendering the first page as cover, render it as XHTML. This means that if the EPUB is not valid XHTML the cover wont be rendered correctly. Necessary for rendering of SVG elements in the page when it does not have an .xhtml extension. Fixes #7909 (Issue with HarperCollins EPUB Covers)

This commit is contained in:
Kovid Goyal 2010-12-15 18:34:03 -07:00
parent 1140fb8f0c
commit 5cd412a7d5

View File

@ -122,7 +122,11 @@ def render_html(path_to_html, width=590, height=750):
renderer = HTMLRenderer(page, loop)
page.connect(page, SIGNAL('loadFinished(bool)'), renderer,
Qt.QueuedConnection)
page.mainFrame().load(QUrl.fromLocalFile(path_to_html))
# Can't use load as if the extension of path is not xhtml
# then it won't render SVG correctly, so set mimetype
# explicitly
page.mainFrame().setContent(open(path_to_html, 'rb').read(),
'application/xhtml+xml', QUrl.fromLocalFile(path_to_html))
loop.exec_()
renderer.loop = renderer.page = None
del page