EPUB is the abbreviation for electronic publication. It is a file format for publishing books and other types of content in a reflowable fashion. This means that the content can adapt itself to fit the available screen space. An EPUB file can be viewed on a 3.5″ cell phone as well as a 10″ tablet or the 22″ monitor of a desktop computer. If the line width is adjusted, the text reflows to make optimum use of the available screen estate. Images can get scaled to achieve the same effect.
An EPUB publication consists of a single file that has the file extension .epub. Below is the official logo for EPUB files, published in June 2010 by IDPF.
This page provides a general overview of the EPUB file format. It discusses
- The basics of the file structure
- Font handling
- Image embedding
- How the create EPUB files
- How to view or read EPUB files
- Troubleshooting EPUB files
- A comparison with other file formats
The page ends with some pointers to other interesting sites.
The file format
EPUB is based on three open standards:
- Open Publication Structure (OPS) – An EPUB 2.0 file uses XHTML 1.1 to construct the content of a publication. In essence this means that an EPUB file consists of one or more web pages. Even though you could include the entire content of a book or newspaper in a single page, it is better that such a file doesn’t exceed 300K, both for performance and compatibility reasons. Just like with regular web pages, the styling and layout is defined using cascading style sheets (CSS). In EPUB files a subset (limited series of commands) of CSS2 needs to be used. Many of the new features of CSS3, such as rounded boxes or drop shadows, are not available yet. For backwards compatibility, a creator can also use DTBook instead of XHTML to encode the content.
- Open Packaging Format (OPF) – This part of the specs deals with structural information such as metadata (who is the author and the publisher, what is the title,..), the manifest (a list of all the files inside an epub file) and the table of contents. These data are all embedded using XML.
- Open Container Format (OCF) – As the above descriptions should have made it clear an EPUB document consists of a series of files. The OCF specs define how all those files end up being packaged in one single container file. ZIP compression is used for this. If you take an EPUB file and change the .epub extension to .zip, you can decompress the publication and take a look at all those files.
Font handling in EPUB files
There are two 2 mechanisms for handling fonts in EPUB files:
- Since an EPUB file is a collection of web pages, fonts can be referenced in the CSS.
- Embedding fonts: Font embedding is a technique in which characters shapes (glyphs) are included in a file. a As far as I know it is best done using OpenType fonts & @font-face in CSS.
- Useful to maintain a specific look & style.
- Practical for math books or to maintain diacriticals (accents,…) and other non-ASCII characters.
- Not all EPUB readers support embedded fonts.
- Not many font licenses allow for this type of distribution.
Images in EPUB files
The EPUB file format supports the following image file formats:
The standard is flexible, meaning that it is permitted to use additional file formats, such as Flash. If that is the case, the EPUB file needs to include an alternate rendering of that file in one of the 4 above supported file formats. This means that you can embed a movie in an EPUB file but the software creating the file should maybe take one of the initial frames of the movie and embed it as a JPEG image. A reader device such an an e-book reader that cannot display movies can then display the JPEG image instead.
How to view EPUB files
I often use Adobe Digital Editions, a free EPUB viewer from Adobe, to read EPUB files. Digital Editions can be a bit quirky. If an EPUB file contains errors, it may crash.
Since FireFox is my main browser, I also have the EPUBreader plug-in installed.
With the exception of the Amazon Kindle, most other e-readers on the market can display EPUB files. Since I am not that happy with the currently available devices, I don’t have much experience with them.
How to create EPUB files
For people who are familiar with designing for print, using Adobe InDesign to create EPUB files may be the easiest solution. The InDesign Export for digital editions menu option can be used to export a publication to an EPUB file. You can find a set of tutorials here.
You can find an interesting summary of EPUB creation tools here.
Troubleshooting EPUB files
No information available yet
Other sources of information
The full specifications of EPUB can be found on the IDPF site.