It is convenient to place longer documents in multiple HTML files. For, example, you might place each chapter in its own HTML file. Web pages handle multiple HTML files by having internal links that allow the reader to jump from one HTML file to another. In eBooks multiple HTML files are handled by supplying a separate file that lists the reading order of the files. For EPUB and Mobi documents this function is performed by a package file having extension opf, e.g., content.opf. The EPUB specification also requires several other files used for navigational and organizational purposes. We will describe each of these required files. An EPUB document is merely a compressed zip file containing the HTML files and other required files making up the document. Below is the recommended directory structure for the EPUB files:
- OEBPS/content/ (directory for your html files)
- OEBPS/CSS/ (directory for your style files)
- OEBPS/image/ (directory for your image files)
The mimetype file must have this name, must be in the root directory, must be exactly 20 bytes in size, and must contain the following text (no line feeds, carriage returns, or extra spaces)
This file is the same for all documents so it only needs to be created once.
The file container.xml must have this name and must be in the directory META-INF. An example container file is shown below.
<rootfile full-path=" OEBPS/content.opf" media-type="application/oebps-package+xml"/>
The only thing in this file that is subject to change is the path to the opf file (underlined above). The directory does not have to be named OEBPS, but some readers have trouble with other names. The opf file name does not have to be content.opf, but again this is conventional. If we stick with the conventional directory and file name, then this file does not vary from document to document.
The file content.opf provides some basic information about the document, lists the files that make up the document, and specifies the reading order of the document's html files. The file doesn't have to have this name, but the name has to be that specified in container.xml. The next section contains an annotated example OPF file.