Generating a Kindle-compliant ebook with KindleGen

 
 
Part 19: combine your ebook cover, HTML, OPF and NCX files to make a MOBI ebook suitable for Amazon.
 
By the end of this article, you should have an Amazon-compliant MOBI book file which you can read in Kindle Previewer, or on your Kindle – and, of course, upload to Amazon. Now, as I see it (and I could be very wrong on this), there are two ways to generate this MOBI: the ‘correct’ way, and a shortcut.

Generating a MOBI via Kindle Previewer (the shortcut)

This appears to generate the required MOBI file, but as I’ve not tried to upload the results to Amazon, I can’t say whether it will leave something important out during the generation process. My head says no; my paranoia say yes, and that they’re following me. All of them.
 
1. The first thing you want to do is place your HTML, OPF, NCX and cover JPG into the same folder.
 
2. Launch Kindle Previewer.
 
3. Drag the OPF file from the folder into the Kindle Previewer window.
 
4. Allow the small electronic goblins contained within time to work their magic.
 
5. Kindle Previewer should output a MOBI file into a folder within your containing folder, called compiled-yourbooktitle.opf.
 
6. It will also create a pop-up window called ‘Compilation Details’, which you can scroll through to view details of the compilation process and any errors which occurred. Now, one of three things is going to happen:
 
i) you will get the error message ‘Kindle Previewer has failed to compile the book’ (and if you do, see below),

Failed generation
At which point it’s perfectly acceptable to swear loudly

ii) the book will compile, but with warnings (again, see below), or
 
iii) the book will compile, and you and the goblins will dance a merry jig around your study.

Generating a MOBI via KindleGen (the ‘correct’ way)

KindleGen is a command line tool. There is no graphical interface, and you can’t double click on the EXE to launch it. This is old school computing. Stop me quick before I tell you how long it used to take us to network multiplayer Doom over four computers via DOS in 1995. Note that I have reworked a lot of what Cassandra Davis has to say about this process.
 
1. You will be typing the folder location where you store KindleGen at least twice and probably many more times, so make the path as simple as possible. Unzip the Kindlegen package to c:\KindleGen (assuming that c:\ is your primary hard drive for program files), then move your HTML, OPF, NCX and cover JPG into the same folder.
 
2. Navigate to start → all programs → accessories → command prompt.
 
3. In the DOS window, type:
c:\kindlegen\kindlegen.exe c:\kindlegen\yourbooktitle.opf
 
4. You can’t hotkey a cut and paste into the DOS window. Note that ‘yourbooktitle’ should be replaced with the actual filename used for the book. And watch that space between the two commands, or you’ll be typing everything out again.
 
5. The filename must be exact, i.e. no ‘htm’ for ‘html’.
 
6. KindleGen seemed to struggle with underscores_in_the_file_name when I used it. Your mileage may vary.
 
7. And, because you’ve gone to the trouble of making the OPF file, you actually have to point KindleGen at this. If you point it at the HTML file, it will compile the book without the OPF, i.e. no cover or contents location.
 
8. KindleGen will output a MOBI to the KindleGen folder.

Warnings and failures

Chances are that there will be a tag here or there that you have forgotten to close, or an incorrect filename that will cause your book compilation to fail. These will be displayed as error messages in the DOS window, designated by line number where possible, and you can run back over your code and fix any of these errors. It may make you go crosseyed, but there will be something in there throwing a spanner in your ebook.
 
If you’re still struggling with an error or warning, try entering it into Google as a search term. Chances are that the problem has happened to someone before, and that it’s been solved in a forum somewhere.
 
Note that the I8000: No page map found in the book error refers to the fact that your ebook won’t have page numbers, as previously discussed.

Success

Once you’ve fixed the cause of any errors and failures, and successfully generated a MOBI file, you can transfer this to your Kindle’s ‘documents’ folder and open it like any other ebook. It’s a good time to reread your novel for lingering typos, because seeing it in a new format will make them more clear.
 
Congratulations. You’ve just published your own novel. The next section of articles will deal with the fun stuff: uploading, marketing and actually convincing people to buy it.

Proceed to Part 20: ‘Cataloguing in publication (CiP)’, or return to the article index.
Return to Re: writing
While I’ve endeavoured to provide you with accurate information, what is considered ‘accurate’ will change over time. If I’m wrong, or you’d like to ask a question or share your thoughts, I’d love to hear your take on things.

Rhys About Rhys

Teacher, writer, editor, cook: a bit like that nursery rhyme, really.
Facebook / Google+ / Twitter

Comments

  1. Thanks so much for posting this. I was testing graphics sizes and resolution with a new book and suddenly, the Kindle Previewer couldn’t compile the book. The epub validator came out fine and I hadn’t changed anything that should have caused a problem. I spent about 2 hours trying to figure out the problem, even going back to a previous version, but with no luck. Then I found and followed your instructions to see if I could generate a mobi from the dos line using kindlegen instead of going thru the previewer and it worked!!! And there is nothing wrong with the book … works fine on both kindles and the kindle for pc app. You saved me from a bad night’s sleep:-)

    • There is nothing like that feeling of beating your head against a problem and getting nowhere for a while, and then suddenly finding a solution that works. Glad I could help.

  2. Ahmad Faiq says:

    Thanks My friend…!

Speak Your Mind

*