EPUB/Converting ODF to EPUB

From The Document Foundation Wiki
Jump to: navigation, search

This page discusses the process of Converting ODF to EPUB.

Which Formats?

There are many possible routes for converting ODF -> EPUB. In this section, we'll focus on the conversion of ODT -> EPUB, using (in general) tools that support ODF 1.2 and EPUB 3.

EPUB Support in LibreOffice

In LibreOffice, there's currently an enhancement request: tdf#33226 - [FILEOPEN/FILESAVE] EPUB Documents. If that support is implemented, export directly from LibreOffice will probably become the best method for ODT to EPUB conversion.

In the meantime, there are multiple tools that produce EPUB output...

Tools

Tool Version Test Input Test Output Testing Notes General Notes
LibreOffice + Writer2ePub extension LO 4.2.3.2 + Writer2ePub 1.1.25 v4.2 - Introducing LibreOffice chapter FAILURE.
No Output
  • Warnings about many not-supported styles
  • No header, so no TOC
  • Failed with Error 423: Property or method not found: CLSID. In Module: Graphics - At line : 273
LO 4.1.2.2 + Writer2ePub 1.1.25 v4.2 - Introducing LibreOffice chapter FAILURE.
No Output
  • Warnings about many not-supported styles
  • No header, so no TOC
  • Failed with Error 423: Property or method not found: CLSID. In Module: Graphics - At line : 273
Media:Regressions.odt FAILURE.
No Output
  • Warnings about many not-supported styles
  • Failed with Error 91: Object variable not set. In Module: Graphics - At line : 133
Tool Version Test Input Test Output Testing Notes General Notes
LibreOffice + eLAIX extension (EPUB 3) LO 4.2.3.2 + eLAIX 4.0.3 v4.2 - Introducing LibreOffice chapter EPUB output
  • Warning: (would not let me proceed) "Please structure your document by headings. You need at least one heading. To do so, put the cursor into the first line of your document and click on "Format as Heading 1" in the eLAIX Toolbar."
  • After heading added per instructions, export was successful
Output looks quite good.

Some indentation/document structure appears to be better than Calibre ODT->EPUB
Button on toolbar says "Export EPUP [sic] Document..."

LO 4.2.3.2 + eLAIX 4.1.0-2014-04-13 v4.2 - Introducing LibreOffice chapter EPUB output
  • Warning: (would not let me proceed) "Please structure your document by headings. You need at least one heading. To do so, put the cursor into the first line of your document and click on "Format as Heading 1" in the eLAIX Toolbar."
  • After heading added per instructions, export was successful
Output looks quite good. Similar to 4.0.3 release

Specific bugs with the export:

  • Title page is missing (same in eLAIX 4.0.3)
  • Bulleted points are not converting properly (See "Using the Save As command above, select..." and "To activate it:")
  • Headings such as "Minimum requirements" lose their green color
  • Tables sometimes break across pages in EPUB. Switching to "flow mode" (e.g. in Calibre's ebook-viewer) helps to alleviate this problem.
  • Content aligned by Tab ↹ characters (e.g. "Jean Hollis Weber Tab ↹ Peter Schofield") is squished together after export
    • This might be a consequence of how tabs appear in HTML
  • Missing table border/stroke around images such as "Figure 3: Example of tearing...")
  • The Undo/Redo button images (e.g. the icon immediately following the first "Undo icon" in the text) are inline (Anchor -> As Character) in the ODT, but sit above the line of text in the export.
File:GS4201-IntroducingLibreOffice-HB.odt - With Boldt's tweaks File:GS4201-IntroducingLibreOffice-HB.epub Harry Boldt, author of eLAIX, provided a modified ODT that is more easily converted to EPUB
File:GS4201-IntroducingLibreOffice-HB tabs-to-tables.odt File:GS4201-IntroducingLibreOffice-HB-tabs2tables.epub EPUB (read: HTML) doesn't handle tabs properly, so I replaced tab-aligned formatting w/tables
  • To convert TABS -> TABLES
    1. Make sure there's a blank line between each line containing tabs
    2. Select all the lines, then Table -> Convert -> Text to table -> OK
    3. Now remove the extra vertical spacing by deleting the extra line in the cells on the RIGHT
    4. Click inside the table, then Table -> Table Properties
    5. Table Format -> Borders -> Line arrangement -> Default -> (Click) Set No Borders
    6. (Also in Borders) go to 'Spacing to contents' -> (Set 'Top' and 'Bottom' to 0.00")
  • To find the TABS in the first place
    1. CTRL + F to find, then click on the Magnifying glass
    2. Other Options -> (Select) Regular Expressions
    3. Then Search For "\t"
Tool Version Test Input Test Output Testing Notes General Notes
Calibre (ODT -> EPUB) Calibre 1.9 v4.2 - Introducing LibreOffice chapter EPUB output Good output, competitive with eLAIX.

Preserves green header color (eLAIX does not)

Calibre: PDF -> EPUB Calibre 1.9 File:GS4201-IntroducingLibreOffice.pdf EPUB output Poor results, no where near as good as the eLAIX 4.0.3 output.
Tool Version Test Input Test Output Testing Notes General Notes
LibreOffice + Writer2XHTML extension Writer2LaTex 1.2 beta (2012-03-13) v4.2 - Introducing LibreOffice chapter EPUB output
  • Use Extension Manager to install the Writer2xhtml.oxt
  • Export and use "Save as type" dropdown select "EPUB (.epub)(*.epub)"
  • support for JRE must be enabled (tested with JRE 7u51)
Support for HTML5 and EPUB (3.0) not yet implemented. Renders good document structure and TOC from headers, but some graphics are not incorporated into the EPUB rendering. Installs and functions as export filter on all LibreOffice builds through 4.3.0alpha+ builds of master. Primary focus of Writer2LaTex project is LaTex, EPUB support an off shoot of projects XHTML support.

Best Practices for Conversion

Because of limitations in the conversion process, this section will contain a set of "Best Practices" that will help authors improve the ease with which their ODT documents may be converted to EPUB.

  • eLAIX requires a heading (e.g. 'Heading 1') used in the document
  • Tests have indicated that some converters do not correctly convert bulleted/numbered list styles; direct formatting may be preferable

Notes from Harry Boldt re: eLAIX conversion testing:

  • Most problems however appeared, because eLAIX needs style names such as "Heading 1..4" for headings and "Illustration" for image captions. I know, it should be possible to use own style names everywhere. I will correct this in future versions.
  • The title page: eLAIX starts reading from the first heading, what means, that all stuff placed before is not exported. Your title page is a good example, that this is not a good solution. So I will change the export in the way, that everything will be exported, regardless of the occurence of headings.
  • Lists: eLAIX is assuming, that a new list starts, when the style is changing. In your document, you use "Start - Continue - End" styles for lists, what is a good practice. Unfortunately I wasn't aware of that. So I have to find a better solution here.
  • Headings: As long as there is no better solution in eLAIX, please do not change the style name for headings. Leave them the way, LO generates it "Heading 1", "Heading 2" and so on. If you do so, the styling of your headings will be reflected in the ePUB.
  • TABs in content: They are not supported so far. It's on the to do list.
    • (Work-around: Use a table instead)
  • Table border/strokes missing in Figure 3: Can you explain more detailed, what you mean? I can't see a border.
  • Small graphics/icons: I have to test in more detail, why your small graphics an missplaced in the ePUB. If you click on the appropriate eLAIX toolbar button "Graphic Align Inline", they will be properly exported. What is then been done behind the scenes is: AnchorType=AsCharacter, HoriOrient=Left, TextWrap=None.
  • Image Captions: It is really hard, to recognize an image caption in LO by macro. Internally, the caption is not saved as an image property. LO just generates a paragraph below the image. Therefore, in order to identify an image caption, eLAIX looks for the style "Illustration". Not the best solution, I know. Using the style "Illustration" for image captions will lead to the standard HTML5 construction: <figure><img src=".."><figcaption>Caption</figcaption></figure>.
  • Use the character style "Standard" for general settings of your ePUB such as font-family, font-color, font-size, font-weight, text-decoration and text-align. Those settings will be generated as CSS rules for the body tag of the ePUB document. As long as these settings aren't overwritten by other paragraph settings, they will be inherited.
  • eLAIX does not remove special characters like "/" and "." from styles at the present. So as long as this isn't fixed, do not use special characters for paragraph, frame or character styles, since they won't work in the ePUBs CSS.

Links