Generating EPUB documents with a click
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).
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).
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.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.