FB2

From MobileRead
Jump to: navigation, search

FB2 stands for Fiction Book version 2. It is the eBook format described at FictionBook.org

Contents

[edit] Goals

The stated goals of the FictionBook project are:

  • The main objective is to accurately keep the book structure
  • It should allow effortless converting (including automatic) of FictionBook files to other popular formats: TXT, DOC, RTF, HTML and so on.
  • To provide reader applications that allow reading the FictionBook format without converting.

This format is being developed by several Russian software developers to have a unified archive electronic format for books that can be converted as needed to other formats. Currently the specification is most suited for fiction books.

[edit] Specification

Current version of FB2 specification is 2.2.

Format is defined in terms of W3C XML Schema which is available from the project site here

Specification is developed by the tightly-knit team of Russian e-libraries holders.

[edit] Description

Here is a high level description of the elements slightly modified from the FB2 site and supplemented with examining the file. These are only examples and not the full list of supported tags. The file is not compressed at all, plain TXT markup, but some reading programs support zipping it to reduce the size. All of the data is in the one file. There is the standard XML header consisting of:

<?xml version="1.0" encoding="windows-1252"?>
<FictionBook xmlns:l="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink"
 xmlns="http://www.gribuser.ru/xml/fictionbook/2.0">

Be sure the encoding is set correctly to the proper character set. If you need special characters that are not in the defined character set the html style "#number;" designation can be used to define it. This is followed with three main sections: <description>, <body> and optionally <binary> containing any images encoded as base64 (similar to how RTF does it). An element called <stylesheet> is defined but often not used as the reading program will usually have its own defaults. If present it is based on CSS and included first.

[edit] stylesheet

The stylesheet elements immediately below root contain stylesheets; their type attribute contains the MIME type of stylesheet. It is recommended to include one text/css stylesheet to ease conversion to other formats if any styles are used in the document.

[edit] description

The description section contains the metadata for the eBook. It is divided into four main categories: title-info, document-info, publish-info, and custom-info. Only the first two are normally present. Comments are permitted using <! -comment -! >. A sample title-info looks like:

<title-info>
 <genre match="100">nonfiction</genre>
 <author>
   <first-name>firstname</first-name>
   <last-name>lastname</last-name>
 </author>
 <book-title>The name of the book</book-title>
 <annotation><p>The description of the book</p>
  </annotation>
 <date value="2010-03-10">March 10, 2010</date>
 <coverpage>
   <image xlink:href="#cover.jpg"/>
 </coverpage>
 <lang>en</lang>
</title-info>

Multiple genre sections may be entered. Multiple author sections can be entered. A <middle-name> and <nickname> can also be used. The annotation (description) can be more than one paragraph. The date field can have an optional value field which is intended to be machine readable. The second section is the document info which might look like:

<document-info>
 <author>
   <nickname>person</nickname>
 </author>
 <program-used>Book Designer 5.0</program-used>
 <date>11/29/2008</date>
 <src-url></src-url>
 <src-ocr></src-ocr>
 <id>BD-36A225-16FB-4841-14AE-6218-8022-529F8D</id>
 <version>1.0</version>
</document-info>

The Publish-info block is used when the document is created from a hardcopy edition. It has a few bibliographical fields like book-name, publisher, city, year and isbn.

[edit] body

The next major part of FictionBook document is body that contains the actual book’s text. The first body element is always the main subdocument in the book. Subsequent bodies can be used to store footnotes, comments and other stuff that does not belong to the normal text flow in the book. Each body element can contain an optional title, optional epigraph and at least one section.

There are two distinct kinds of sections. One contains other subsections only, and the other contains actual text paragraphs. It is not possible to mix subsections and paragraphs inside the same container in the current version of FictionBook standard. Each section can have a number of optional header fields: title, epigraph, image, and annotation. After these, there must be at least one paragraph-type element for text sections or at least one subsection for others.

All text in the document is stored in the body section. The following paragraph-type elements: p, v, and subtitle. An <empty-line/> element that has no content is used to insert one line of vertical space. A few more complex containers are built from these basic elements: title (contains any number of p and empty-line), annotation, poem, cite, epigraph.

The <section> tag is used to provide a chapter and <title> shows the name and is picked up to generate the TOC. A sample might look like:

<section>
<title>
<p>Chapter I: First Chapter</p>
</title>
<empty-line/>
...

The FictionBook provides a few elements for hyperlinking, an essential feature for electronic documents in our modern times. Hyperlinks in FictionBook are based on the XLink specification from the W3C consortium, and are a subset of the XLink. The only links are for images and notes (footnotes). A note link will be shown as a superscript and might look like:

<a xlink:href="#N2" type="note">2</a>

An image tag might look like:

<image l: href= "#picture.jpg "/>

Other tags that are supported include <emphasis> for italics and <strong> for bold text.

[edit] Binary

Binary elements are quite simple too and contain any base64-encoded opaque data that might be needed to render the document. They must always have the id and content-type attributes. They will be referenced via an href tag which must use the #targetname format to access the image within the file. An image begins with, for example, <binary id="targetname" content-type="image/jpeg">

[edit] For more information

see: FictionBook description

Graphic flow charts the FB2 schema

[edit] Software

List of software using or producing FB2 may be found at project site (rus, extensive) and (en, less extensive). Notable examples:

There are converters to support FB2. These may be found at: http://fictionbook.org/index.php/Eng:Converters This is the English page but doesn't seem to be in English yet.

  • Any2FB2 - Interactive conversion of TXT/HTML/MS Word documents to FB2. May work with HTTP and download linked documents|images. May be used as an ActiveX server from JScript, Perl and so on. Freeware, open source.
  • fbtools.org - OpenOffice.org extension to OCR text correction and conversion to FictionBook format.
  • Batch2FB - A Shell for the package conversion of files into fb2 format. It makes it possible to convert the list of the selected files, to add in the list all supported files from the directories with subdirectories support, to unpack and to add in the list a zip archive.
  • FB2Any - A collection of Windows- programs for converting fb2 into different format and work with the books (sending into the device and the like). Currently in development.
  • Doc2fb2 - convert books in DOC or RTF format to FB2 preserving markings and pictures. Conversion of DOC files requires MS office 2003.
  • Book Designer can create or convert to FB2 and many other formats.
  • FB2EPUB is a web site for online FB2 to EPUB conversion. Based on epubgen code which can also be run locally (epubgen is currently a part of epub-tools)
  • fb2epub.com online tool for converting FB2 files to ePUB format. Supports fonts sub-setting and embedding.
  • fb2mobi.com online tool for converting FB2 files to MOBI format.
  • Web2FB2 is a web site that will convert a URL to FB2 and ePUB format.
  • FictionBook Tools - includes FB2 Validator, FB2 files editor, and Infotips and columns provider for Windows Explorer. These tools are for a Windows PC.
  • Wiki2FB2 is a web site to convert Wiki pages to FB2 format.

[edit] eBook Readers

The format is supported by the following eBook Readers

[edit] Usage and popularity

The format is very popular in Russian-speaking community, as three of four largest Russian e-text libraries use this format extensively:

LitRes - prominent Russian e-book seller, tightly related to the before mentioned libraries, also uses fb2 as the internal and external format for e-books.

English books in FB2 format can be found at:

Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox