Practical examples

Building the example book

The example below shows the how the example book is assembled. If you want to play around with it, you will find the examples project in the Git repository.

Adding a cover

Correctly adding a cover to a publication can be a bit awkward as different reading systems expect different input. So there is a shortcut:

<cover image="cover.jpg" title="My Title"/> 

Simply point to the file in question and this EPUB tooling will take care of the rest. There is of course another, more laborious way allowing more control. The procedure is as follows:

  1. Add a cover image to the publication
  2. Add a HTML file using the image
  3. Reference the HTML file
  4. Add a meta element pointing to the image

Assuming the cover image is at hand we will add it using the item element as this:

<item file="images/cover.jpg" id="cover-image"
  type="image/jpg" spine="false" />

Next we add a XHTML file (named cover.html) to the publication. This will be used by some reading systems.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
<html xmlns="">
    <title>Cover Page</title>
    <style type="text/css">
      img { max-width: 100%; }
    <div id="cover-image">
      <img src="cover.jpg" alt="Building EPUBs"/>

Then some more Ant code:

<item file="cover.xhtml"/>
<reference href="cover.xhtml" 
  type="cover" title="Cover Page" />
<meta name="cover" content="cover-image"/>

Both methods will produce a cover page that will work with all the tested reading systems; including Syny Reader PRS-T1, Calibre, iBooks, Nook for Mac, Adobe Digital Editions for Mac and Kindle (after converting to MOBI using Calibre).

The cover of this book as it is rendered on Nook for Mac.

The end result can be something like the illustration above – showing the cover of the example book as it is rendered on Nook for Mac.