Workarounds for Exporting to EPUB

LibreOffice and Calibre

By

With a little workaround knowledge and Calibre, you can get the most out of LibreOffice’s EPUB export function.

Starting with the 6.0 release, LibreOffice supports export to EPUB format. Although an extension for EPUB export has been available for several years, this feature is long overdue, considering the growing popularity of ebooks. Unfortunately, though, using ebook export is not as simple as selecting an option from File | Export As. Unless you are exporting the simplest of document designs, many of LibreOffice’s features are not exported. Just as efficiently exporting to HTML requires a special approach to document design, a successful EPUB format requires a few workarounds, or else editing the result in Calibre or another tool like Sigil. Since, post-export editing requires a knowledge of Cascading Style Sheets (CSS), for most users, the easiest place to make adjustments is in the original document.

The simpler a document, the more likely that it will to export to EPUB without problem. If a document is entirely text, most likely you can select File | Export As | Export Directly to EPUB and let LibreOffice do the work using the default export settings. Probably, you also can successfully use File | Export As | Export as EPUB; this allows you to tweak the metadata that is otherwise borrowed from your user settings and File | Properties, such as where page breaks occur and the cover image for the export file. However, although Export as EPUB offers the option for a fixed format, the setting applies mainly to page breaks, and the formatting options remain limited (Figure 1).

Figure 1: LibreOffice offers a few controls for EPUB export, but drops many common formatting choices.

At the opposite extreme, if you require elaborate formatting – as in a brochure – the format for you is probably PDF. An offshoot of the Postscript printing language, the PDF format is well-equipped to handle any design you care to use, although online forms in particular can be challenging. LibreOffice has had PDF export for years, and the options available from File | Export As | Export as PDF allow fine-tuned control (Figure 2).

Figure 2: In contrast to the EPUB export controls, LibreOffice’s PDF controls offer a rich array of options.

However, if your formatting is somewhere in the middle of these two extremes, you can still use EPUB export control with some success, so long as you know what design features are available and how to workaround some of the deficiencies.

Basic Design Limits

Successful EPUB export is often a matter of trial and error. It may take several attempts to get the desired results. For that reason, you can save yourself effort if you use character and paragraph styles, which allow you to quickly make adjustments. Other LibreOffice styles – frames, pages, lists, and tables – are not recognized by the EPUB export filter, but you can use them for your own convenience.

EPUB does not support character and paragraph styles, but you can count on font size, line spacing, alignment, and font color to export. If you have formatted some characters differently from the rest of the text, the difference is preserved, including subscript or superscript. Footnotes and endnotes are also preserved, as well as hyperlinks

However, that is the end of the good news. Any characters that are not entered directly or by fields are lost and will not appear in the output. That means that while list items are preserved, bullets and numbers entered from the toolbar or by a list style are dropped – so are cross references based on page numbers and headings and useful fields like page numbers.

Similarly, any sort of text frame is simply dropped. Text in sections, text frames, columns, and captions are exported, but only as regular paragraphs. The same is true for drop capitals. Text in table cells is also imported, but with erratic spacing and text formatting that makes it unusable.

Worst of all, no graphics or objects created using the Drawing toolbar are exported.

If designing for EPUBS sounds like a study in limitations, you are beginning to get the right idea.

Some Basic Workarounds

This advice is worth repeating: the simpler the document design, the less trouble with exporting to EPUB. The trouble, of course, is that you often need the features not supported by EPUB export. Fortunately, other ways exist to get the same results. At times, you can even use the limitations themselves to find a workaround.

To start with, if features cannot be exported automatically, you can export them by entering them manually. For example, if you want a bulleted list, use Insert | Special Character and enter the bullet character manually (Figure 3). Keep in mind that you cannot indent a list item's second line to align it with the first line of text rather than the bullet, so you will want to keep your list items short. Cross references can also be entered manually, although admittedly at the cost of increased maintenance if you edit documents. If you are using the Fixed setting in the Export as EPUB window, you can also manually enter headers and footers, including lines to separate them from the rest of the text, by adding them to each page.

Figure 3: If you want a bulleted list in an EPUB export, you have to add the bullet character from the Special Characters dialog window.

If you want a drop capital, you can create one by adding a text box (Insert | Text Box), inserting a large capital into it, and adjusting the space between the capital and the right and bottom of the frame and the surrounding text. Exporting will drop the frame, leaving the capital and the space around it. Text boxes can also be added to create a multicolumn layout, although you need to be aware that EPUB reduces the spacing set between columns in LibreOffice.

Still more features can be preserved by not using the LibreOffice export features at all. Instead, install Calibre and export the original LibreOffice file into Calibre. Calibre has its own export filters, and the one for EPUB is much more versatile. For instance, Calibre exports graphics and preserves their alignment. While it takes the first graphic for a cover, that can be edited later (Figure 4).

Figure 4: Calibre is useful for touching up EPUB exports.

Another useful feature of exporting with Calibre is that, while it cannot reproduce cross references based on page numbers or headings, it can reproduce those made with bookmarks.

Other workarounds depend on a knowledge of CSS. You can, for example, specify a font to use, rather than letting users choose their own. However, the use of CSS to produce ebooks is a lengthy subject and deserves an article to itself.

Other Considerations

LibreOffice probably chose to add EPUB support, because it is an open standard. Kindle/Mobi is not an open standard, but if you need that format, export your LibreOffice or EPUB file into Calibre – or, better yet, export the original LibreOffice .odt file, since the fewer conversions done means the less trouble you are likely to have. However, I am still investigating the limitations of converting to the Kindle/Mobi format.

Be aware, too, that the various validators online for different ebook uses can sometimes have wildly differing results. Some may not permit a fixed file, so check the preferred format before you begin. Since an EPUB file that reads well in Calibre may not be acceptable for a particular use, you should always refer back to any standards that the output file is required to meet.

As open source software, LibreOffice offers a convenient graphical interface for producing ebooks. For now, its EPUB tools remain basic, but, with the addition of Calibre, you can still have an open source tool chain for producing ebooks. Should both those applications fail to give the results you want, then look into CSS, which can be edited in Calibre or the text editor of your choice.

Related content

comments powered by Disqus

Issue 216/2018

Buy this issue as a PDF

Digital Issue: Price $12.99
(incl. VAT)

News