November 3, 2011

Possible Code to Fix the Double Cover Issues on eBooks

THIS ARTICLE IS DEPRECATED DUE TO NEW REQUIREMENTS FROM AMAZON


If you take the advanced route and work with EPUB code to format your eBooks, it may be advantageous to have a separate XHTML file that can be accessed to display the cover image. I like to link to this file in both the eBook's HTML Table of Contents and the meta Table of Contents (NCX) in case the reader wants to check out the cover. There's a file in my EPUB package that has the following code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<title>Cover</title>
<style type="text/css">
  @page {padding: 0pt; margin:0pt;} <!--Remove for MOBI-->
  body {text-align: center; padding:0pt; margin: 0pt;}
  div {padding:0pt; margin: 0pt;}
  img {padding:0pt; margin: 0pt;}
</style>
</head>
<body>
<div>
<img src="cover.jpg" alt="The Book's Cover" style="height: 100%;" />
</div>
</body>
</html>

In the content.opf file, the brain of the eBook, the coverpage.html file is located at the beginning of the spine section to indicate that it should show up first. This works swell for eBook readers like Adobe Digital Editions. However, you will get two cover images after you run your EPUB through KindleGen and upload to the Amazon Kindle Store. This is because Amazon requires the following code in the metadata section of the content.opf file:
<meta name="cover" content="My_Cover_ID" />

And the following code is in the manifest:
<item href="cover.jpg" id="My_Cover_ID" media-type="image/jpeg" />
<item href="coverpage.html" id="coverpg" media-type="application/xhtml+xml" />
So when the reader pulls up your eBook in the Kindle the get two cover images on two different pages at the beginning. This was apparent in the new Steve Jobs Biography, which means Simon & Schuster was having the same problems as the rest of us.

As a workaround to the double cover issue, you can try adding the following XML into the spine section:
<itemref idref="coverpg" linear="no" />
The linear attribute is "yes" by default, and it makes the section inside the eBook available, but it cannot be accessed by page turning. It should be a good method, but unfortunately nothing ever works as its supposed to in the MOBI format. Both the Kindle and Mobipocket stick the cover in the back for some reason with strange results when you try to click through the navigation with prev/next section or prev/next page.

Conclusion: It looks the best option for the Kindle is to completely remove the coverpage.html file and adjust the Table of Contents as necessary making no reference to the coverpage.html. If anyone has a better way, I'd sure to like to hear it.
Share/Bookmark

1 comment:

Unknown said...
This comment has been removed by a blog administrator.