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 (170 KB | 28 pages)Get Adobe® Reader®

Activity:  194576 views
Comments:  

Before you start

This tutorial guides you through creating eBooks in the EPUB format. EPUB is an XML-based, developer-friendly format that is emerging as the de facto standard for digital books. But EPUB isn't just for books: With it, you can:

  • Bundle documentation for offline reading or easy distribution
  • Package blog posts or other Web-native content
  • Build, search, and remix using common open source tools

About this tutorial

Frequently used acronyms

  • API: application programming interface
  • CSS: Cascading stylesheets
  • DOM: Document Object Model
  • DTD: Document type definition
  • GUI: Graphical user interface
  • HTML: Hypertext Markup Language
  • SAX: Simple API For XML
  • W3C: World Wide Web Consortium
  • XHTML: Extensible HTML
  • XML: Extensible Markup Language

You start this tutorial by generating an EPUB book manually to help you learn all the components and required files. Next, the tutorial shows how to bundle the finished digital book and validate it against the specification as well as how to test it in various reading systems.

Then, it covers generating EPUB from DocBook XML—one of the most widely used standards for technical documentation—and how to use Python to completely automate EPUB creation with DocBook from end to end.

Objectives

In this tutorial, you:

  • Learn what EPUB is, who's behind it, and who's adopting it
  • Explore the structure of an EPUB bundle, including its required files and their schemas
  • Create a valid EPUB file from scratch using simple content
  • Use open source tools to produce EPUB files from DocBook, a widely used schema for technical documentation and books
  • Automate EPUB conversion using Python and DocBook

Prerequisites

No particular operating system is assumed for this tutorial, although you should be familiar with the mechanics of creating files and directories. Use of an XML editor or integrated development environment (IDE) is strongly recommended.

For the later parts of the tutorial on automating EPUB creation, this tutorial assumes that you know one or more basic XML processing skills—XSLT, DOM, or SAX-based parsing—and how to construct an XML document using an XML-native API.

No familiarity with the EPUB file format is necessary to complete this tutorial.

System requirements

To complete the examples in this tutorial, you need a Java interpreter (version 1.5 or later) and a Python interpreter (version 2.4 or later) as well as the required XML libraries for each. However, experienced XML developers should be able to adapt the examples to any programming language with XML libraries.

1 of 9 | 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
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).

Special offers