Producing ePub Documents from InDesign
Producing ePub Documents from InDesign
Authoring an InDesign document
There are several important things to keep in mind while authoring the document in InDesign:
-
Text styling:
In the latest version of InDesign CS4 (v. 6.0.3), local formatting export is supported. Make sure you select the 'Local Formatting' option under Base for CSS styles in the Digital Editions Export Options dialog.
In earlier versions of InDesign (including CS3) only Character Styles, Paragraph Styles, and Object Styles are exported to ePub. All freehand styling is discarded.
This means that if you want a single word or phrase in bold type, you need to create a character style (i.e. bold_text),
and apply this character style to all of the text that you need to be bold. If you then decided that you want some of
those words bold and italic, then you must create a second style to apply to those select words to be turned bold
and italic.
Font embedding:
in general, all fonts that are used should to be embedded. It is important to
understand that this includes styled versions of fonts (i.e. bold or italic).
In order for a font to be embedded in the exported ePub:
- the font family must be an OpenType font. Most TrueType fonts are also supported, but
you should always test to see if a particular font you plan to use works. - the font must be applied somewhere in the document (unused styles will not be embedded)
- the font family must be an OpenType font. Most TrueType fonts are also supported, but
- Chapters: a good ePub file should contain a separate XHTML stream for each section or chapter. So, if you're planning on a final EPUB file size of over 300KB (especially if it will be viewed on a mobile device), every section of your eBook should be created as a different document in InDesign. This is especially important in long or complex eBooks. Dividing the work into separate documents makes styling each section easier, and will make the pages render faster in ADE. In order to export a full book from InDesign, you must select the export command from the "Book" panel menu, instead of the "File" menu, as it is for documents. Make sure that you have the "Book" panel visible (automatically pops up whenever you open a book in InDesign). The export tool will only export character/paragraph styles and metadata from one document in the book. This document can be selected from the book panel menu as the "styling source" document (the little symbol to the left of the document name).
Layout:
when threading together text frames, they will always be exported in the correct order. However,
they will also always be in one flow. All of the layout editing that you have done to place the
text frames with respect to each other or the page is discarded. You will have to style the layout
of the ePub manually, after export.
Custom CSS styling:
when you apply a character/paragraph/object style to the corresponding element in InDesign,
the style name will become the value of the class attribute of the subsequent <div> tag
in the xhtml file. The current version of the export tool does not support any way to set the
id attribute directly from InDesign.
Images and objects:in the export tool, if the "formatted" box under the images section is checked, the images
will be reformatted to a smaller size (the size that you have scaled them to in InDesign) in order
to decrease the file size. If you would like to keep the original images, make sure to uncheck this
box (it is checked by default). Unless anchored, images and objects will be placed pretty arbitrarily
in the ePub. It is a good practice to anchor your images to the relative area you want them in the text,
or they may end up towards the beginning or end of the document. You will have to work with the images
after export anyway, but anchoring them to text saves you some time repositioning them later. Unfortunately,
an anchored frame can only contain one type of object. This means that you cannot anchor an image and
a caption in the same anchored object. The order in which content is added to the document does not influence
the order in which it appears in the ePub. However, the order of the content in InDesign also does
not correspond perfectly to the order in which it appears in the ePub. Manual styling is necessary.
Image Captions
For image captions to export correctly to EPUB, you'll need to paste them as a group inline with the text and then create an anchored object. Follow these tips to complete this process:
- Select the frames containing the image and the caption text and then choose Object > Group
- Transfer the group to the clipboard using Edit > Cut
- With the Text Selection tool, select the location in the text flow to which you want the group to anchor
- Paste the object inline in the text frame using Edit > Paste
- Using the Selection Tool, select the inline group
- Select Object > Anchored Object to create and specify the offset and behavior of the anchored group
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:
- Using a zip compression/decompression tool, extract the contents of the ePub archive to a known location.
- Apply the required edits to the individual components
- 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. - 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
- Open the xhtml file.
- 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.
- Manually move the <div> tags so that all paragraphs and objects are in a generally correct order.
Changing the Chapter Order
- Open content.opf
- 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. - Save and close content.opf
Step 2: Creating Separate Style Sheets
Creating separate style sheets has several advantages:
- It allows you to style different sections in a more logical and less limited way
- If you decide to edit the InDesign and re-export, having separate style sheets allows you to avoid manually re-editing everything you have done with the stylesheet previous to the export.
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.
- Open toc.ncx
- 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.
- 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.
- Open content.opf
- 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"
- 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.
