OpenOffice to HTML for Kindle

Amazon’s Kindle Direct Publishing platform will not allow you to upload an OpenOffice file. The file needs to be converted to another format.  There are tools that you can get to help you make the conversion, but for this example we’ll assume you don’t have access to any of those tools and you’ll be doing everything in OpenOffice.

Prepare the File

Before starting the final formatting process, you want to make sure that your copy is as clean as possible. If you haven’t read Getting Stated with Open Office, you may want to do so before continuing.  This guide assumed you used the three styles suggested there.

  • Remove any extra spaces.

The easiest way to do this is to use the search and replace option of OpenOffice.  Press <CTRL><F> to display the find window. In the “Search For” field press the space bar twice.  In the “Replace” field press the space bar once. Press the “Replace All” button to replace two spaces to once space.  Repeat this until OpenOffice can no longer find anything to replace.

  • Remove extra blank lines.

In the View pull down window select the Nonprinting Characters.  That will display a paragraph mark at end of each line. (¶).  It is a toggle, so clicking it once will display the characters. Clicking it a second time to stop displaying them.

Look for any places where you left extra blank lines and remove them.  The most common places will be around your section break and at the end of each chapter.  You can use the search function <CTRL><F> to locate your section break quickly.

  • Add your front matter before the start of the novel.

For an ebook this may consist of your title page, copyright page and dedication.  Amazon uses the first 10% of your book as the sample preview.  Your front matter is included in that 10%.

  • Add your back matter after the end of the novel.

This may include a preview to your other books, a call to action on the part of the reader and an about the author section.

  • Add your table of contents at the very end of the book.

Read Adding a Table of Contents to your Ebook in OpenOffice to learn how to create one.

 Save the file as HTML

  • In the File pull down menu select “Save As”. Change the “Save as type” to HTML Document and then save the file. If you have Automatic file name extension checked, the file will be saved with .html at the end. If not, you should add the .html yourself.
  • To keep this simple, I’ll assume you named your file novel.html
  • When you press the “Save” button, you may be prompted to “Keep Current Format” or “Save in ODF Format.”  Pick Keep Current Format to save the file as HTML.
  • Now you have an HTMLfile. You’ll need to make  a few changes to it before you can upload it to KDP.
  • Close OpenOffice.

Edit the HTML

  • Find your copy of novel.html
  • Rename the file to novel.html.txt and open it with OpenOffice.  We don’t want OpenOffice to try to fix the html. By changing the extension to txt we can avoid a lot of potential issues.  An alternate solution is to edit the file in text editor like WordPad.

Fix the Styles

At the beginning  of the HTMLfile you will see a style section.  It will look a lot like this:

<STYLE TYPE="text/css">
<!--
@page { margin: 1in }
P.BookSpacer-western { font-family: "Arial", sans-serif; font-size: 10pt; widows: 4 }
P.BookSpacer-cjk { widows: 4 }
P.BookSpacer-ctl { widows: 4 }
P.BookBody-western { font-family: "Arial", sans-serif; font-size: 10pt; widows: 1 }
P.BookBody-cjk { widows: 1 }
P.BookBody-ctl { widows: 1 }
H1.western { font-family: "Times New Roman", serif; font-size: 16pt }
H1.cjk { font-family: "Microsoft YaHei"; font-size: 16pt }
H1.ctl { font-family: "Mangal"; font-size: 16pt }
A:link { so-language: zxx }
-->
<STYLE>

The styles were generated by the styles that you used in OpenOffice.  If you followed the suggestions in the early example, you’ll have three styles: BookBody, BookSpacer and H1.  OpenOffice adds font information to the styles.   We are going to remove the font information so that the readers can use whatever font they prefer on their device.

A style line is basically broken into 3 segments: a type, a name and a set of attributes.  For example P.BookSpacer-western { font-family: “Arial”, sans-serif; font-size: 10pt; widows: 4 } has a type of P (for paragraph), name of BookSpacer-Western, and the  attributes are enclosed in the squiggly brackets { }. When the style is used, you’ll see something like <P CLASS=”BookSpacer-western”> which is the translated to p.BookSpaper-western.

Removing everything between the { } lets the document use the default set of attributes for that part of the document.

I like to center the spacer character I use between sections, so I put text-align: center between the { } for the BookSpacer style to override the default behavior (which is to justify the text to the left and right).

For the body of the book, I only want to set the indent used for each paragraph.  This is controlled by the BookBody style. I put text-indent: 0.25in in the brackets to create an indent that is a quarter of an inch.

I don’t do any additional formatting for the chapter titles, so I clear out the attributes for the H1 style.  Since every chapter will be formatted the same way, the H1 style doesn’t have a name associated with it.

If you want to try different attribute values, you can look at
kdp.amazon.com/help to find their current HTML formatting guidelines

Below is an example of what it will look like when I am done.

<STYLE TYPE="text/css">
<!--
@page { margin: 1in }
P.BookSpacer-western { text-align: center }
P.BookSpacer-cjk { text-align: center }
P.BookSpacer-ctl { text-align: center }
P.BookBody-western { text-indent: 0.25in }
P.BookBody-cjk { text-indent: 0.25in }
P.BookBody-ctl { text-indent: 0.25in }
H1.western {  }
H1.cjk {  }
H1.ctl {  }
A:link { so-language: zxx }
-->
<STYLE>

 

Identify the Table of Contents

Find your table of contents in the file.  The table of contents needs to be named “toc” if we want the device to find it correctly.  If you see <A NAME=”toc”> right above the table of contents, you won’t need to do anything. The odds are you won’t see that.  In that case, add the following lines right above the table of contents.

<P STYLE="text-indent: 0in; page-break-before: always"><A NAME="toc"></A>
<BR/>
</P>

This will place an anchor named “toc” at the top of the page where the table of contents is located.  With that in place, when the reader selects to go to the table of contents this page is what will be displayed.

 

Identify the Start of the Novel

I like to have the reader open the book to Chapter 1 allowing them to bypass the front matter content.  To do this, I first had to find the Chapter 1 heading in my html file, and then add a <A NAME=”start”> right above it.

<P CLASS="ebook-body-western" STYLE="page-break-before: always"><A NAME="start"></A><BR>
</P>
<H1 CLASS="western" STYLE="page-break-before: always"><A NAME="__RefHeading__12386_204851746"></A>
Chapter 1</H1>

This will place an anchor named “start” at the top of the page where Chapter 1 begins.  In the above example, I added the  paragraph text block (shown below) around the anchor (<A NAME=”start”></A>).  This seemed to prevent he problem of having the start anchor link to the middle of the page.

<P CLASS="ebook-body-western" STYLE="page-break-before: always"><A NAME="start"></A><BR>
</P>

Once the Anchor is in place, selecting Beginning on the Kindle will take you to correct spot.

I noticed that when using the online previewer from the KDP bookshelf that the start attribute was ignored.  To verify that the start anchor is working correctly, download the .mobi file and copy it to your Kindle.

Wrapping It Up

Save your file and if you need to change the name back to novel.html.  Once the file has the html extension you can view it in your default browser by double clicking on it.  The formatting won’t look like a book in the browser, but there are a few things that you should check right away.

  • Is each paragraph indented?
  • Is your section break centered?
  • Is each chapter in a heading format?
  • Do you have a table of contents at the end and do the links work?

If those items look good, then you are ready to upload the file.

Uploading the file

I jump right to my KDP bookshelf and upload the file as a draft copy.  When I preview it I want to see what Amazon will be working with, and this is the best way to do that.

Fist I preview it with the online previewer, then I download the HTML and MOBI files that KDP produced to view the novel on my own device.  The MOBI file I copy to my kindle using the USB connection.  The HTML file is going to be downloaded as a zip file. I normally don’t do anything with this file, but if my preview looks different than I expect I will compare my original HTML file to the HTML file I downloaded to look for any discrepancies.

 

Other Links

Calibre – Calibre is a free and open source e-book library management application developed by users of e-books for users of e-books.  This is my quick and dirt solution for creating a mobi file when I just want to proof a file on my Kindle.

Sigil – Sigil is an Epub editor.  I don’t have much experience with it, but Daniel Price posted a nice guide to Google+.  You can click here to see it.

 

 

Awesome, Heroic Fantasy Stories