Monday, May 9, 2011

Creating eBooks for the Kindle

Being the kind of person to like to learn how things work, I decide to delve into the process by which one can create a Kindle eBook.  One reason for this is the Kindle book Smashwords created for me does not appear to play well on Kindle devices.

I've been creating books since then with Scrivener, which does a much better job. It calls Kindlegen directly. Amazon gives away this program for anyone who wants to make their own Kindle editions.  

Accompanying Kindlegen is a sample eBook.  It's the User Guide for the Kindle that is pre-installed on the device for you.  I looked at the source files to see how to create an eBook according to Amazon's rules.

Basically, you supply HTML files (one per chapter).  The files should reference an external CSS file for styles and you should create one or more folders for the images you want to use in the book, if any.  In this way, an eBook is identical to a web site.  So if you've ever created a web site you are most of the way.  However, if you look at the Kindle formatting guidelines, not all HTML tags are supported and not all CSS definitions work.

In addition to the images, style sheet, and content you provide, you also need to create three files that create the eBook when Kindlegen is run.  The first file is an OPF file.  This is an XML file that defines the HTML files to use, provides metadata about the book and a few other things.  It is self-documented so I won't bore you here with the details.

The second file is a TOC file, called toc.html.  It provide the table of contents for your ebook.  I recommend making one so users can jump to specific locations in your book.

The third file is a NCX file.  This is an XML file that defines the sections of your eBook, like the TOC file, and controls navigation in the eBook.  Again I won't bore you with the details here.

When you supply these files and tell Kindlegen to process the OPF file, it creates an eBook with the name xxx.mobi, where xxx is the name of the OPF file.

Using a version of Kindle software for your computer, you can then preview the book to see what is working and what it not.

And that's about all there is to know. Happy Kindle generation.

No comments: