About the EPUB format
Learn the background of EPUB, what EPUB is most commonly used for, and how EPUB differs from the Portable Document Format (PDF).
EPUB is the XML format for reflowable digital books and publications standardized by the International Digital Publishing Forum (IDPF), a trade and standards association for the digital publishing industry. IDPF officially adopted EPUB in October 2007 and by 2008 had seen rapid adoption by major publishers. You can read the EPUB format using a variety of open source and commercial software on all major operating systems, e-ink devices such as the Sony PRS, and small devices such as the Apple iPhone.
Although traditional print publishers were the first to adopt EPUB, nothing in the format limits its use to eBooks. With freely available software tools, you can bundle Web pages as EPUB, convert plain text files, or transform existing DocBook XML documentation into well-formed and valid EPUB. (I cover the latter in From DocBook to EPUB.)
PDF is still the most widely used electronic document format in the world. From a book publisher's point of view, PDF has several advantages:
- PDF files allow pixel-perfect control over layout, including complex print-friendly layouts such as multiple columns and alternate recto/verso styles.
- PDFs can be generated by a wide variety of GUI-based document tools, such as Microsoft® Office Word or Adobe® InDesign®.
- PDF readers are ubiquitous and installed on most modern computers.
- Specific fonts can be embedded in PDF to control the final output exactly.
From a software developer's point of view, PDF falls far short of the ideal:
- It's not a trivial standard to learn; therefore, it's not a simple matter to throw together your own PDF-generating code.
- Although PDF is now an International Organization for Standardization (ISO) standard (ISO 32000-1:2008), traditionally it has been controlled by a single corporation: Adobe Systems.
- Although PDF libraries are available for most programming languages, many are commercial or are embedded in GUI applications and not easily controlled by external processes. Not all free libraries continue to be actively maintained.
- PDF-native text can be extracted and searched programmatically, but few PDFs are tagged such that conversion to a Web-friendly format is simple or reliable.
- PDF documents aren't easily reflowable, meaning that they don't adapt well to small screens or to radical changes to their layouts.
EPUB addresses all the flaws in PDF as they relate to developer friendliness. An EPUB is a simple ZIP-format file (with an .epub extension) that contains files ordered in a proscribed manner. There are a few tricky requirements about how the ZIP archive is prepared, which will be discussed in detail later in Bundling your EPUB file as a ZIP archive. Otherwise, EPUB is simple:
- Nearly everything in EPUB is XML. EPUB files can be built using standard XML toolkits without any special or proprietary software.
- EPUB content (the actual text of an eBook) is almost always XHTML version 1.1. (An alternative format is DTBook, a standard for encoding books for the visually impaired. See Resources for more information on DTBook, which is not covered in this tutorial).
- Most of the EPUB XML schemas are taken from existing, published specifications that are freely available.
The two key points are that EPUB metadata is XML and EPUB content is XHTML. If your documentation-building system produces output for the Web and/or is based on XML, then it is very close to being able to produce EPUB, as well.