Open Source Musings The thoughts, ideas, and opinions of an open source guy

Creating an ebook with LibreOffice Writer

An ebook reader

If you have an idea for a book, you’re no longer at the mercy of an editor at a big (or even small) publishing house somewhere. Thanks to computers, we can all be publishers – and for more than just one day.

Yes, you guessed it. ebooks are the great leveler. Or, at least, they can be. If you have a fairly recent Linux distro and LibreOffice Writer you can publish your own ebooks quickly and easily.

OK, you’re probably thinking: using a word processor as an ebook publishing tool? There’s no reason why you can’t. People have written and published ebooks using LibreOffice Writer (and OpenOffice.org Writer) in the past. Admittedly those ebooks were PDFs but …

Thankfully, PDF isn’t the only ebook format in town. An arguably better one is EPUB. Thanks to an extension called Writer2ePub, you can use LibreOffice Writer (and OpenOffice.org Writer, too) to publish ebooks in EPUB format.

Let’s take a look at how.

Getting set up

The first thing to do is download the extension. From there, fire up LibreOffice Writer and select Tools > Extension Manager and then click Add. Find the extension, and then click Open. You’ll have to restart Writer.

You’ll notice a new toolbar:

Writer2epub toolbar

Now, you’re ready to go.

Preparing your ebook

That’s pretty simple. Just start writing as you normally would. You’ll need to keep your entire book in one file. Writer2ePub doesn’t work with master documents. At least it didn’t when I was using it – the toolbar disappeared whenever there was a master document window open.

When you’re preparing content for conversion to EPUB with Writer (and even if you aren’t), always keep this in mind: use styles. Don’t apply formatting manually – for example, don’t create a heading by highlighting text, making it 22 point DejaVu Sans, and applying bolding. Apply the Heading 1 style instead.

The reason you need to do this is simple. EPUB files are very structured. Styles, while they can help make a document look nice, are there to enforce consistency and structure. If you don’t use styles, there can be problems. The biggest one is that the table of contents for your EPUB file won’t generate properly. Which means you won’t have proper navigation or structure.

Generating your EPUB

That’s easy. Open your book file and then just click the Writer2EPUB button on your toolbar. You’ll be prompted to enter metadata (information about the book).

Adding metadata

At the very least, you need to enter:

  • Your name (or the name of the author, if you’re doing the conversion for someone else
  • The title of the book
  • The book’s language

You can also tell Writer2ePub where to find a cover image for the book. Assuming, of course, you created one. If you haven’t, then maybe you should consider doing that before going any further.

Once you’re ready to go, click OK. I’ll be honest: I’ve only experimented with files about 50 or 60 pages long at the most. That said, the conversion was fairly fast and quite smooth. The book looked good to boot.

Checking out your book

So you’ve got an EPUB file. It has the extension .epub, to boot. What now? You should check out your book. A great way to do that is to open it in Sigil. Sigil is a WYSIWYG tool for creating EPUB files, and it’s also a good application for viewing and checking your files.

Checking your ebook in Sigil

If you’ve done everything properly, then the EPUB you created in Writer should be fine. Chances are, though, you won’t like the default look and feel of the text. I don’t. It’s not ugly, just not to my liking.

To fix that, you can edit the stylesheet that controls the formatting of the book. You can do that in Sigil, obviously.

Something else you should do is validate your EPUB. Validation is the process of making sure that your EPUB books contain all the elements that ebook readers expect. Like what? Here’s a partial list:

  • Complete metadata
  • The proper directory structure in the EPUB file
  • Valid XHTML
  • Working links and references to files in the EPUB file
  • A table of contents

All of that should be fine, but it’s best to check. To do that in Sigil, select Tools > Validate Epub. Validation only takes a few seconds but it’s a useful step.

Final thoughts

While Writer (or any other word processor) isn’t my first choice for writing a book, it’s possible to use it to do the deed. And with Writer2ePub, you’re not stuck with just PDF as an ebook format.

Thoughts? Let's start a conversation on Twitter.

Did you enjoy this post or find it useful? Then please consider supporting this blog with a micropayment via Liberapay. Thanks!