Metamorphosis

The writer2ePub plugin for OpenOffice Writer converts formatted files to compatible data for many of the popular e-book readers at the press of a button.

The Open/LibreOffice suite of programs owes its popularity to the stability of the software and its extensibility through plugins. Thanks to its modular design, you can customize the program to suit your needs in just a few simple steps. In addition to a plugin for importing simply designed PDF files [1], OpenOffice also has an extension that lets you convert text from Writer to the open EPUB format [2]. With the right choice of software, these documents are then available for PCs and smartphones.

Approach

Standalone programs for generating EPUB documents are of very limited use for composing text. They usually offer only basic functions for designing a cover page and formatting the text. Programs like eCub or Jutoh fail if the document to be edited contains hard line breaks or you want to use a justified layout. Automated functions such as search and replace are not available or, in many cases, are only rudimentary. Thus, you have to consider preparing the files that need to be converted to EPUB format with a word processor up front; then, when you save the data, you must make sure to store it in a readable format for EPUB-building software to keep as much formatting as possible.

The OpenOffice writer2ePub [3] extension takes a completely different approach. This OpenOffice Writer component converts an existing document directly from ODT to EPUB format, removing the need to use a separate program and eliminating that annoying post-editing work. Similarly, you have no need to learn the details of the EPUB format and its many tags.

Installation

To add the writer2ePub plugin to an existing OpenOffice or LibreOffice installation, first download the appropriate (OXT) file from the web [4]. Pay attention to your office suite version; writer2ePub comes in three version: one for OpenOffice 3.x, one for version 4.x, and a beta version with additional features. After downloading, click Tools | Extension Manager to open the dialog for adding plugins. Press the Add button, look for the OXT file you saved, and add the extension.

When you restart OpenOffice, you will see three new icons on the far left in the OpenOffice toolbar, or in the beta version, you click the writer2ePub icon on the left to open a new pane with the icons (Figure 1).

Figure 1: The beta version of writer2ePub opens a separate pane for its functions.

The rightmost icon, Preferences, lets you set the default global settings for the EPUB generator. Only a few basic options are available, and it is usually fine to keep the default values (Figure 2). By clicking the center button, you can add metadata to a document, such as the title and author of the work, the ISBN number, and year of publication. You also can choose the e-book cover here. If the details for the main metatags are missing, the OK button is grayed. The empty data fields then have a red label, so you can see at a glance where information is missing (Figure 3).

Figure 2: Set up writer2ePub quickly with a few options.

Figure 3: Field names are red and the OK button is grayed when required information is missing in the Meta Data dialog.

Hands On

In our lab, we tested writer2ePub with various text files initially formatted in OpenOffice 3.4.1 and LibreOffice 3.5. When converting, the plugin achieved quite reasonable results: It easily converted simple text without special formatting such as footnotes or tables of contents to EPUB. However, in more complex texts, some errors occurred, or the process stopped.

The plugin added images to the document; however, you will want to center them in the original OpenOffice document to avoid potentially moving text around. The images can also use various formats. It does not matter whether they are line drawings or color photos, but you do need to pay attention to the file size: In the plugin Preferences dialog, an Image Dimension Limit (Kb) entry lets you define the maximum size of embedded graphics and images as needed. Larger values here are not necessarily beneficial: The more pictures you add to the text, the slower the finished document loads.

The software also converts unformatted files in .txt format without problems. One thing you notice when you view simple files like this in standard EPUB readers is that they often use the wrong fonts. For example, a file opened in FBReader using the standard Courier font was converted to a document in italics.

Because left-justified text can be difficult to read, depending on the window size, it makes sense to justify the document left and right. To do this, select the default style in OpenOffice. This gives you an easily readable serif font, which you can then change in size to suit your needs. Special paragraph attributes, such as bold, italic, and underline, are also possible. Once you have adjusted everything, highlight all the text and click the Justified icon.

Note that you cannot use automatic hyphenation if you want typical readers to render the file correctly. The hyphenation function in OpenOffice in particular trips up FBReader, causing it to separate words without using hyphens. After completing the formatting, you need to save the document in ODT format and then generate the EPUB document by clicking the leftmost button. The software creates a file in your working directory with a .epub suffix.

Results often depend on which e-reader is used to look at the EPUB file. Okular, the default reader in many distros, failed to place the image correctly, allowing text to flow behind it, and it lost the left justification (Figure 4). FBReader, however, placed the image well and maintained justification but converted the font to sans serif instead of the Liberation Serif font used in the original document. The built-in KDE e-book viewer, however, used the correct typeface, although text with hyphenation appeared gappy in a small display window.