Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Build a digital book with EPUB

The open XML-based eBook format

Liza Daly, Software Engineer and Owner, Threepress Consulting Inc.
Photo of Liza Daly
Liza Daly is a software engineer who specializes in applications for the publishing industry. She has been the lead developer on major online products for Oxford University Press, O'Reilly Media, and other publishers. Currently she is an independent consultant and the founder of Threepress, an open source project developing ebook applications.

Summary:  Need to distribute documentation, create an eBook, or just archive your favorite blog posts? EPUB is an open specification for digital books based on familiar technologies like XML, CSS, and XHTML, and EPUB files can be read on portable e-ink devices, mobile phones, and desktop computers. This tutorial explains the EPUB format in detail, demonstrates EPUB validation using Java technology, and moves step-by-step through automating EPUB creation using DocBook and Python.

05 Feb 2009 - As a followup to reader comments, the author revised the content of Listing 3 and refreshed the epub-raw-files.zip file (see Downloads).

27 Apr 2010 - Refreshed the epub-raw-files.zip file (see Downloads).

03 Jun 2010 - At author request,revised the content of Listings 3 and 8. Also refreshed the epub-raw-files.zip file (see Downloads).

11 Jan 2011 - At author request,revised the content of Listing 5. Changed second line of code from <item id="ncx" href="toc.ncx" media-type="text/xml"/>; to <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>.

12 Jul 2011 - As a followup to reader comments, revised the content of Listing 14. Removed ` character near end of first line of code from <?xml version="1.0" encoding="utf-8"?`>. Revised code now reads: <?xml version="1.0" encoding="utf-8"?>.

Date:  13 Jul 2011 (Published 25 Nov 2008)
Level:  Intermediate PDF:  A4 and Letter (504 KB | 25 pages)Get Adobe® Reader®

Activity:  234241 views
Comments:  

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).

What is EPUB?

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.

Who is producing EPUB? Is it only for books?

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.)

How is EPUB different from PDF?

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.

Three standards in one

EPUB consists of three separate IDPF specifications, although in practice, it's safe to refer to them collectively as EPeUB:

  • Open eBook Publication Structure Container Format (OCF): Specifies the directory tree structure and file format (ZIP) of an EPUB archive.
  • Open Publication Structure (OPS): Defines the common vocabularies for the eBook, especially the formats allowed to be used for book content (for example, XHTML and CSS).
  • Open Packaging Format (OPF): Describes the required and optional metadata, reading order, and table of contents in an EPUB.

Additionally, EPUB reuses several other standards, such as XHTML version 1.0 and Digital Accessible Information SYstem (DAISY), for specific types of content within the EPUB archive.

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.

Why EPUB is friendly to developers

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.

2 of 9 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Mobile development
ArticleID=485946
TutorialTitle=Build a digital book with EPUB
publish-date=07132011
author1-email=liza@threepress.org
author1-email-cc=dhatten@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.