From MobileRead
Jump to: navigation, search

OPF is the open packaging format that is defined by idpf. Version 2 is the internal file metadata used in ePub. Some use it as an alternate name for the version 1 standard which was officially called Open eBook. MOBI, LIT, and IMP all use a version 1 OPF (.opf) in their source.


[edit] Structure

The OPF file can be located anywhere in the ePub file structure and can be named whatever you wish. In ePub there is a folder called META-INF that must always be present. Inside there must be a file call container.xml. The content of that container file points to the OPF file. It might look like:

<?xml version="1.0"?>
<container version="1.0" 
   <rootfile full-path="Ops/content.opf" 

[edit] Specification

The Open Packaging Format (OPF) Specification, defines the mechanism by which the various components of an OPS publication are tied together and provides additional structure and semantics to the electronic publication.

Specifically, OPF:

  • Describes and references all components of the electronic publication (e.g. markup files, images, navigation structures).
  • Provides publication-level metadata. Specifically it should include: dublin core formatted data
  • Specifies the linear reading-order of the publication.
  • Provides fallback information to use when unsupported extensions to OPS are employed.
  • Provides a mechanism to specify a declarative table of contents (the NCX).
  • May provide pointers to additional optional elements such as embedded fonts.

[edit] Example

See ePub OPF section for one example. For an example of Version 1.2 see Open eBook Package File. Here is another 2.01 example:

<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" 
 <metadata xmlns:dc="http://purl.org/dc/elements/1.1/"  
   <dc:title>Harvard Classics Shelf Of Fiction, Vol III</dc:title>
   <dc:creator opf:file-as="(Editor), Neilson William Allan" 
     opf:role="aut">Neilson, William Allan (Editor)</dc:creator>
   <dc:description>A Sentimental Journey through France and Italy by 
       Laurence Stene (a travelog novel) and Pride and Pejudice by Jane 
       Austin (Novel of manners, a satire) with bibliographic record, 
       criticisms and interpretations.</dc:description>
   <dc:publisher>Generally the publisher of eBook version.</dc:publisher>
   <dc:identifier id="BookId">AWP-77552DCD-7724-4F66-
   <dc:rights>public domain source first published 1917</dc:rights>
   <meta name="cover" content="cover"/>
  <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
  <item id="style" href="style.css" media-type="text/css"/>
  <item id="coverstyle" href="cover.css" media-type="text/css"/>
  <item id="id001" href="001.html" media-type="application/xhtml+xml"/>
  <item id="id002" href="002.html" media-type="application/xhtml+xml"/>
  <item id="cover" href="images/cover.jpg" media-type="image/jpeg"/>
  <item id="img1" href="images/img1.jpg" media-type="image/jpeg"/>
 <spine toc="ncx">
  <itemref idref="id001" linear="no"/>
  <itemref idref="id002"/>
  <reference type="cover" title="Cover" href="001.html"/>

[edit] Mobi specific

Mobi and the newer Kindle AZW and KF8 formats need special entries in the OPF for the TOC and Cover. You need to add the "TOC" entry in the GUIDE section of the OPF in order for the TOC option to be made available.

  <reference href="Text/Frontmatter.html#coverpage" type="cover"/>
  <reference href="Text/Frontmatter.html#coverpage" title="Start here" 
  <reference href="Text/Frontmatter.html#TOC" title="Table of Contents" 

The OPF file can be used to create an eBook using MobiPocket Creator or KindleGen simply by using it as the starting point for the compiler. It will find the other files necessary by parsing this file.

[edit] Unique id

The web site http://www.famkruithof.net/uuid/uuidgen can provide a unique id for an eBook as needed in the OPF.

Personal tools

MobileRead Networks