
This is a sample Epub-format digital book in Japanese.
Epub is an open digital e-book format adopted by Apple iBookStore, Google Editions and Sony readers.
Epub can be used as an input format for an Amazon Kindle book too.
The content of this sample was taken from the following site as of 2009 September:
Epub eBooks Tutorial (with a sample hand-written .epub book)
(Currently this page is part of more elaborated Epub tutorial)
The Epub format is a ZIP file containing XHTML body text files and some XML files such as table of contents and list of files. All these files are hand-written with a text editor.
This sample was originally created at the time of Epub 2.0 (2009-Sep-18). Then some features adopted in Epub 3.0 that allow traditional japanese writing are added (2011-Nov-3). This time, I used a beta version of Epubcheck (3.05b), a Epub 3.0-compliant validation tool, to make the sample strictly (mostly) compliant to the Epub specification.
This time, I preared two separate Epub files for horizontal and vertical reading in order to test how pages advance.
Download: sample-epub.zip
If you want to directly load an Epub file into your viewer, click or touch one of the following links.
If you try both versions, delete the previously loaded file first before loading another.
Horizontal: sample-yoko.epub
Vertical: sample-tate.epub
This sample book consists of the title page and three chapters. The first two chapters are for testing major HTML constructs such as a figure, table, list and link. The last chapter is for testing vertical rendering mode introduced in Epub 3.0.
I show how the sample looks like with the following viewers:
Here are display examples in Digital Edition 1.8.3 under Windows:
|
|
|
|
Click one of the screen images to see only that image.
Horizontal rendering seems OK with both Epub 2.0 compliant Digital Edition 1.7.2 (latest official version as of 12-Jul-09) and preview version 1.8.3 said to support Epub 3.0 partially. However, in 1.8.3, strangely enough, the first page always starts from the right regardless of vertical or horizontal rendering (see Page Progression Direction for detail).
Vertical rendering is OK with 1.8.3.
Here are display examples in iPad's iBooks reader:
|
|
|
|
Click one of the screen images to see only that image.
There seems no problem in horizontal rendering.
For vertical rendering, as opposed to Digital Edition' case above, the first page starts from left (detail described in Page Progression Direction).
Epub is one of open standards for electronic books (eBook); named after the extension of the file containg the book. International Digital Publishing Forum (IDPF) defined this standard.
The most notable characteristic is, unlike PDF, there is no fixed page boundary. The page boundaries move depending on the screen size and font size chosen at one time. This enabled book reading on a small screen of a mobile device possible.
In summary, an Epub 2.0 book:
Epub defines how to package files, specify page navigation order and write table of contents, but it does not define the content document format. Epub adopts HTML and CSS as its document format and defines subset of them. Therefore, some Epub-compliant eBook readers support HTML and CSS standards beyond the subset defined by Epub.
The latest Web standards (CSS3 and HTML5) that Epub specification depends include support of traditional way of rendering of the document written in the far east countries including Japan. These are adopted in Epub 3.0.
With this sample, I tested vertical writing, ruby (small characters by side), horizontal writing among vertical writing, emphasis dots and line break rule.
The following revisions are made in Epub 3.0:
By the way, what determines the version of an Epub file?
That is, version attribute of package tag in content.opf file:
<?xml version="1.0" encoding="UTF-8"?>
<package version="3.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/"
...
However, it is a viewer that determines what to do:
Epubcheck is a validation tool for an Epub file.
http://code.google.com/p/epubcheck/downloads/list
This is originally developed by Adobe and currently developed as an open source product. For example, the iBooks authoring guide requests a publisher to test its Epub file with epubcheck before uploading to the iBooks store.
As of 2012 July, two versions of Epubcheck are provided for different Epub versions:
I checked the sample file with the 3.0-enabled beta version.
The following are major corrections I made to the sample this time in order to pass epubcheck.
meta http-equiv that specifies a character encoding.
xml declaration and meta charset.
rb and rp tags from ruby tag; only rt tag is used in HTML5.
I could remove all but one error of this sample:
[java] Epubcheck Version 3.0b5
[java] Validating against EPUB version 3.0
[java] ERROR: epub/sample.epub/OEBPS/navdoc.html(12,31): attribute "epub:type" not allowed here; expected attribute "accesskey", ...
[java] ERROR: epub/sample.epub/OEBPS/navdoc.html(6,7): assertion failed: Exactly one 'toc' nav element must be present
[java] Check finished with warnings or errors
[java] Java Result: 1
This error relates to a nav tag in an Epub 3.0 table of contents file (navdoc.html). I am not sure why this happens.
Then I found the page below, followed the same way described there (moved the xmlns:epub declaration from <html> to <nav> element) and received no error.
Epub Tutorial (in Japanese)
I just recently knew that there are two levels of specifications in order to implement vertical rendering in Epub 3.0.
page-progression-direction attribute of spine element in content.opf file.writing-mode attribute.
First, take an example of iBooks reader.
As of 2012-Jul-07, if you read sample-tate.epub with iBooks Reader, the first page appears on the left side of the book.
If you turn pages, lines of each chapter are displayed from right to left.
This indicates file-level specification is effective but book-level specification is not effective.
It seems lack of Epub 3.0 page-progression-direction support in iBooks.
In digital edition 1.8.3, in an opposite way, page direction is right to left even in horizontal rendering although the default value for page-progression-direction is defined as "ltr" (left to right) suitable for horizontal rendering.
I deliberately specified "ltr" for the page-progression-direction attribute but the result was the same.
I hope either will be fixed in a near future.
You can find the following files if you unzip the sample zip file (sample-epub.zip).
epub sample-yoko.epub sample-tate.epub sample/ mimetype META-INF/ container.xml OEBPS/ content.opf toc.ncx navdoc.html title_page.xhtml chap01.xhtml chap02.xhtml chap03.xhtml stylesheet.css images/ koma.png stylesheet-yoko.css stylesheet-tate.css content-yoko.opf content-tate.opf
sample-yoko.epub and sample-tate.epub are Epub format ZIP files.
One for horizontal- and the other for vertical-reading.
Its source contents are in sample folder.
sample-xxxx.epub is a ZIP file containing the contents of the sample folder.
If you rename the file extension of sample-xxxx.epub to "zip" and unzip it, you can get the original contents of the folder.
The following files are meta files conforming to Epub standard.
| mimetype | File for informing that this is an Epub-format ZIP file. |
| META-INF/container.xml | A file that indicates the location of the OPF file below. |
| OEBPS/content.opf | List of files comprising the book content. All files including XHTML, CSS and graphics. Order of pages (spine) is also described here. |
| OEBPS/toc.ncx | Table of contents for Epub 2.0 reader |
| OEBPS/navdoc.html | Table of contents for Epub 3.0 reader |
The following files are files that make up the Epub book conent. They are displayable with a web browser.
title_page.xhtml chap01.xhtml chap02.xhtml chap03.xhtml stylesheet.css koma.png
Finally, the following two pairs of files have different content depending on the rendering direction of horizontal (yoko) and vertical (tate).
They are stylesheet and meta file.
Files with "-yoko" are for horizontal rendering.
Files with "-tate" are for vertical rendering.
sample-yoko.epub and sample-tate.epub are created by copying these files to stylesheet.css and content.opf in the sample folder before zipping.
stylesheet-yoko.css stylesheet-tate.css content-yoko.opf content-tate.opf
You need a ZIP tool to build an Epub-format ZIP file from the source.
But there is a troublesome condition.
mimetype must be the first file in the ZIP file and must be uncompressed.
I introduce you three ways to do that.
Linux and Macintosh includes a commmand line tool called Info-ZIP. You can use it from the Terminal in both platforms.
In Windows, you can install Info-ZIP and use it from the command prompt.
Here is how to execute the ZIP command:
cd sample zip -0 -X ../sample.epub mimetype zip -r ../sample.epub * -x mimetype cd ..
Here, -0 option specifies uncompression, -X removes unnecessary header, -r specifies inclusion of subfolders, and -x specifies files to be excluded.
In Windows, you can create a ZIP file by selecting folders and files, right-clicking them and selecting [Send| Compress (ZIP format) Folder].
I tested myself in Windows 7 but expect it work in the same way Windows XP too.
First, select only mimetype and create a ZIP file.
Next, select the remaining files and drop them into the ZIP file.
Let me check it with Info-ZIP.
The unzip -v command can display contents of a ZIP file.
c:\Temp\sample>unzip -v test.zip
Archive: test.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
20 Stored 20 0% 2012/07/05 21:00 2cab616f mimetype
241 Defl:N 163 32% 2012/07/05 21:00 d3c8670a META-INF/container.xml
2006 Defl:N 1156 42% 2012/07/05 23:12 3f5fefff OEBPS/chap01.xhtml
2329 Defl:N 1281 45% 2012/07/05 23:11 7a375863 OEBPS/chap02.xhtml
1938 Defl:N 1070 45% 2012/07/06 01:20 4e103098 OEBPS/chap03.xhtml
1734 Defl:N 749 57% 2012/07/06 01:59 696c89c3 OEBPS/content.opf
0 Stored 0 0% 2012/07/12 05:24 00000000 OEBPS/images/
1914 Defl:N 1197 38% 2012/07/05 21:00 2760b6de OEBPS/images/koma.png
1002 Defl:N 567 43% 2012/07/06 01:59 b8cdba9a OEBPS/navdoc.html
1078 Defl:N 443 59% 2012/07/06 02:00 8325797e OEBPS/stylesheet.css
752 Defl:N 461 39% 2012/07/06 02:00 f7272379 OEBPS/title_page.xhtml
1187 Defl:N 482 59% 2012/07/06 02:00 9cf9d99c OEBPS/toc.ncx
-------- ------- --- -------
14201 7589 47% 12 files
This may be a coincidence, but mimetype is the first file and it is not compressed.
Recently, I work under a programer's development environment (Eclipse) for handling documents. You can use an automation tool called Ant (similar to good old 'make' in UNIX) in Eclipse for zipping an Epub contents or for other batch conversion.
Here is an example Ant task I use to build an Epub file.
<target name="zip-epub" description="create zipped epub file">
<delete file="${epub.file}"/>
<!-- merge non-compressed mimetype and rest of the files in epub folder -->
<zip destfile="${epub.dir}/mimetype.zip" basedir="${epub.dir}" compress="false" includes="mimetype" />
<zip destfile="${epub.dir}/others.zip" basedir="${epub.dir}" level="9" compress="true" includes="OEBPS/** META-INF/**" />
<zip destfile="${epub.file}" update="true" keepcompression="true" encoding="UTF-8">
<zipfileset src="${epub.dir}/mimetype.zip" />
<zipfileset src="${epub.dir}/others.zip" />
</zip>
<!-- delete temp files -->
<delete file="${epub.dir}/mimetype.zip"/>
<delete file="${epub.dir}/others.zip"/>
</target>
You can use Eclipse completely in the same way in Windows, Macintosh and Linux.
See Authoring environment built with Eclipse for detail.
Other related links:
Kobu.Com's related businesses are:
Kobu.Com welcomes questions and comments about this Epub sample. Please contact us if you need some help with text- and XML-based document creation and digital publishing in general.
Presented by: Kobu.Com
Written: 2009/09/18 (First edition)|
Updated: 2012/04/27 (Revised edition)
Updated: 2012/07/05 (Third edition)
Updated: 2013/01/03 NAVDOC epub:type error resolved
The published sample code is a prototype and is not complete.
Please refrain from duplicating the sample code and its document in another place.
This page is link-free. We welcome your questions and comments.