Producing ePub Documents from InDesign

Authoring an InDesign document

There are serveral important things to keep in mind while authoring the document in InDesign:

Post-Export Styling

After exporting the eBook to ePub format, you can manually edit its content and styling. This is easy to do, because ePub format is really a zip file. To edit these components, follow these steps:

  1. Using a zip compression/decompression tool, extract the contents of the ePub archive to a known location.
  2. Apply the required edits to the individual components
  3. Re-archive all of the components. The order of the files in the archive matters. In order to comply to the ePub specification, add the mimetype file first, and make sure that it is not compressed. Next, add the META-INF and the OEBPS directories to an archive.
  4. Make sure that the extension of the archive file is .epub, not .zip.
Note that the XHTML files, chapter list (OPF file) and the CSS stylesheet can be found in OEBPS directory.

Step 1: Correcting Element Order

During export, the order of some of your elements (i.e. text, images, and other objects) may have changed and needs to be corrected.

Changing the Content Order

  1. Open the xhtml file.
  2. If you used paragraph/object styles, the seperate paragraphs (i.e. titles vs body text) and objects will have class tags that you can use to find them in the xhtml file.
  3. Manually move the <div> tags so that all paragraphs and objects are in a generally correct order.

Changing the Chapter Order

  1. Open content.opf
  2. Under the <spine> element, there is a list of item references. The IDs reference the items referenced in the <manifest> element, which in turn link to specific files in the ePub archive. To change the order of the documents in the eBook, simply rearange the order of the elements in the spine.
  3. Save and close content.opf

Step 2: Creating Separate Style Sheets

Creating separate style sheets has several advantages:

To add your own stylesheet, look at the file template.css to see the styles assigned by InDesign. Place your stylesheet file(s) in the archive and link them with XHTML link element like this:

<link href="style.css" rel="stylesheet" type="text/css"/>

You also must remember to include the new css stylesheet in the content.opf file. To do so, add a line like this to the <manifest> tag in the file content.opf:

<item id="style" href="style.css" media-type="text/css"/>

Step 3: Table of Contents

Every eBook should have a table of contents that contains links to specific sections. ePub provides this functionality. If you exported an InDesign book containing several documents, the export tool automatically adds entries for the beginning of every document. Also, if you used the table of contents feature in InDesign, the entries should also be exported (provided you checked the "Include InDesign TOC Entries" box under the "contents" section of the export tool dialogue. However, even if neither of these two scenarios took place, there is still an emptly table of contents template that is included in the ePub file.

  1. Open toc.ncx
  2. The entries for the Table of Contents lie under the <navMap> tag. Each entry is wrapped by a <navPoint> tag and contains a label as well as a link url.
  3. Table entries can be inserted anywhere into the Table of Contents, as long as you re-number the play-order attributes (it is also a good idea to re-number the navpoint id attributes), and can also be nested inside existing entries.

Step 4: Metadata

The ePub format supports a number of metadata entries that describe such things as the title and author of the eBook. The InDesign export tool should automatically export some of these entries, provided that you filled out the data in the File-->Document Info dialogue and checked "Include Metadata" under the general section of the export tool dialogue. Alternately, you can add your own metadata manually.

  1. Open content.opf
  2. Find the <metadata> tag, declare two new namespaces, as follows:

    xmlns:dcterms="http://purl.org/dc/terms/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. Add the metadata entries into the <metadata> tag, e.g.:

    <dc:title>My First Book</dc:title>
    <dc:creator>John Dow</dc:creator>
    <dc:date xsi:type="dcterms:W3CDTF">2006-10-18</dc:date>
    <dc:language xsi:type="dcterms:RFC3066">en-US</dc:language>
    The above means that the book's title is "My First Book", its author is John Dow, it was published on October 18, 2006 and it is written in American English.
IMPORTANT: Do not change the value of the <dc:identifer> tag, as it contains the unique document ID. This ID is needed in order for embedded fonts to function properly, and if you edit it your fonts will not work.