Creating ebooks with open source tools

94

Author: Dmitri Popov

Traditional printed books beat ebooks in almost every respect except one: portability. While it’s nice to relax on the sofa with a book in your hand, lugging a 500-page hardcover volume when you are on the move isn’t all that appealing. But if your favourite book is available in an electronic format, you can easily turn it into an ebook and read it on your Pocket PC or Palm OS device.

To convert a text you like into an ebook, you need two things: the Sunrise desktop conversion tool and the Plucker reader for your mobile device. Actually, Plucker includes its own desktop component, but Sunrise offers some nifty features. Notably, it supports conversion between different encodings, which can come in handy if you plan to read ebooks in languages using alphabets other than Latin. Like Plucker, Sunrise can run on Linux, Mac OS X, and Linux, but it requires Java Runtime Environment (available free of charge at www.java.com). The official Plucker reader is available only for Palm OS-based devices, but there is also a Plucker-compatible open source reader for Pocket PC called Vade Mecum.

The best place to find a good read is the Gutenberg project, which offers a wealth of public domain books for every taste. Many texts provided by the Gutenberg project are already available in the Plucker format, so all you have to do is to download the file you want and transfer it onto your mobile device. This quick-and-dirty method is great for acquiring ebooks with minimum fuss, but it has one serious drawback: the whole ebook consists of a single file. This works fine for short stories, but it may be inconvenient when reading long books. If that’s the case, you might want to download the text version of the book and format it manually. Manual formatting requires time, but an OpenOffice.org macro and a couple of clever tricks can speed the task of producing properly formatted ebooks.

The most serious problem with texts from the Gutenberg project, as well as those from other Web repositories, is hard line breaks. If you don’t want the text in your ebook to have strange line breaks scattered all over the place, you have to remove them. There are other less serious but still annoying problems, such as excessive spaces, that you can fix too. Doing this manually is a daunting prospect but, fortunately, John Vigor designed an excellent macro to deal with these problems. To download it, point your browser to the discussion thread on OOoForum, and locate the Code section in the first post. Copy the code, launch OpenOffice.org, and choose Tools -> Macros -> Organize Macros -> OpenOffice.org Basic. Go to My Macros -> Standard -> Module1, select the Main item in the right pane, and press the Edit button. Paste the copied code into the main window and press the Save button to save the macro. You can then run the macro by choosing Tools -> Macros -> Run Macro and selecting My Macros -> Standard -> Module1 -> ASCII_Formatter_StartHere.

If you plan to use the macro regularly, you might want to add a toolbar button so you can access the macro more easily. To do that:

  1. Go to Tools -> Customize.
  2. Click on the Toolbars tab.
  3. From the Toolbar drop-down list, choose the toolbar you want to use (for example, Standard).
  4. Press the Add button.
  5. From the Category list, choose OpenOffice.org Macros -> My Macros -> Standard -> Module1 and select ASCII_Formatter_StartHere from the Commands list.
  6. Click Add.
  7. If you want to change the name of the macro, press the Modify button and select Rename.
  8. To assign a button to the macro, press Modify and select Change Icon.
  9. Press Close to save the changes and close the window.

The macro button will appear on the main toolbar. Once it’s in place, you can open your text in Writer and press the newly added button to clean it.

Next, you can divide the text into multiple files — for example, one file for each chapter. Writer has a neat feature that allows you to chop a single file into several pieces based on a given paragraph style. To use it, start by applying the Heading paragraph style to each chapter title. To do this in one go, choose Edit -> Find & Replace, enter the search criteria (e.g. ‘chapter,’ assuming that the chapter titles contain the word ‘chapter’), press the Find all button, and select the Heading style from the Stylist window. This applies the selected style to the chapters. Now, choose File -> Send -> Create Master Document, make sure that the Styles field in the dialogue window is set to Heading, and press Save. This saves each chapter as a separate file, and each chapter becomes a part of a master document. Finally, discard the master document, and save each chapter as an HTML file.

Tip: Apply the Text body style to the main text in each chapter. This ensures the correct HTML conversion.

Your ebook is almost ready. It needs only a title page containing links to each chapter. Create a new HTML file that has the following structure:


<html>
<head>
<title>Title</title>
</head>
<body>
<h1>Ebook titles</h1>
<a href="chapter1.html">Chapter I</a><br>
<a href="chapter2.html">Chapter II</a><br>
</body>
</html>

Save it as the index.html file in the folder with all the converted chapters.

Now you can convert the ebook and transfer it onto your mobile device using Sunrise. To add the ebook to Sunrise, launch the application and choose File -> New Item Wizard. Assuming that you already have created a document list, select the I want to create a new Document option. Select the index.html file, adjust the properties, and press the Update button. This produces a .pdb file ready to be transferred to your Palm or Pocket PC. That’s all there is to it.

Dmitri Popov is a freelance writer whose articles have appeared in Russian, British, and Danish computer magazines.