Archive for
February 7th, 2011

This is the ninth installment of a series of articles. To read the previous one, please click here

Okay, it is time for me to finally make good on my promise and turn your book’s HTML source file into a proper eBook. All we need is a little software called Calibre that you can download here.

I want to take a brief moment to point out that Calibre is a free software package and I cannot thank its developer Kovid Goyal enough for putting so much time and effort into this program. Not only is he putting all the effort into writing the application and improving it constantly, Kovid is also very active in his support forums and tries to help everyone with problems whenever he can. So, please feel free to support his restless efforts by perhaps donating a few dollars for the cause. You will find a button on his website and maybe you’d even be willing to commit a small amount every time you actually prepare a new book for publication using his software.

All right, now it’s time to get serious. One of the great things about Calibre is that it allows us to build a variety of eBook formats from the one source file we have so carefully crafted.

The first thing we need to do is to add our new book to the Library. Simply click on the “Add books” button in the upper left corner and select your book’s HTML file. A lot of people do not know that you can actually use an HTML file as a book source in Calibre, but as I pointed out, not only is it possible, it is, in fact, the most reliable way to create a predictable output.

Once you have done that you will see the book appear in the top line of the Library listing. It may have a strange name at this point – Calibre uses the HTML file name by default – but we will fix that in a second.

The next step is to edit all of our book’s meta data. Highlight your book in the Library listing and then click on the “Edit metadata” button in the toolbar at the top. You will now see an input form that allows you to insert all the relevant information about your book on the left side. Most of these fields should be self explanatory, though the “Author Sort” line might be confusing. It is used to allow you to use your last name for sorting. So, instead of “Guido Henkel” I would enter “Henkel, Guido” here.

The large “Comments” field at the bottom is used for your product description. Simply enter your whole flap copy here, your synopsis or whatever you want to call your product description.

Moving on to the right side of the input window you will see a block that is called “Available formats.” Currently it includes only a ZIP file, which is a zipped-up version of our HTML source. Do not do anything else in this block. We will get to it at a later stage.

Finally, lets include the cover of the book into the meta data. This is the cover that will be included in the front of your eBook. It is not the cover that is used by distribution channels to list your book! It is the actual cover image inside the final eBook.

I always create a cover that is at least 1280 pixels wide for use here. Even though many eBook readers do not support color at this point this is nothing you have to worry about. The device will automatically convert this to a grayscale image for you. Purists may say at this point that you should actually create an optimized grayscale image for inclusion for better quality. For the most part I found this not necessary. While the end result might be a tad better – and I stress might here because eBook readers are still notoriously bad at displaying images in general – and while the file size might be reduced, I found the tradeoffs not worth it. Not only would you have to create separate versions for color and grayscale readers, but with the growing proliferation of color devices, you will make it possible for Kindle readers on the iPad, for example, to enjoy the full color version of your cover. That alone should be reason enough to stick with the color cover.

Select “Browse,” find your cover and make sure it displays properly in the meta data window. We now have all our meta data and it is time to click “OK” to make sure they are saved.

Next, click on the “Convert books” button in the toolbar at the top of the screen. This is where the rubber meets the road – from a technical standpoint. Here you find the modules that actually turn our source HTML file into the various eBook formats. While all the menu entries and names might seem extremely technical to you, I will guide you through here to make things easier to understand, especially since most of the technical parameters are identical regardless of the selected output format. Which reminds me… let’s select an output format.

In the upper right hand corner you will find a drop-down menu allowing you to select the output format you want to build. For our purposes right now, select EPUB, which we will be able to use for the Nook, the Apple store, Kobo, Google Books and other outlets.

On the left side of the input window you will see a column of icons. these icons give us access to the different settings for the ePub compiler. Most of these parameters we will leave untouched as the default settings that Calibre provides are real world common sense settings. In fact, we could already press the “OK” button at the bottom of the window and get a decent eBook out of it.

Perfectionists that we are, however, we want to take things a little bit further.

Click on the “Structure Detection” icon and you will see a series of cryptic-looking XPath instructions. Not to worry…

Calibre uses this section to determine your book’s structure so that it can format it properly. For example, this can be used to create page breaks before a new chapter. In fact, it is the default setting. The reason I am taking you here is because in case you do not want to include page breaks here, you will need to switch it off by selecting “None” from the “Chapter mark” drop-down menu.

Next stop, our table of contents (TOC). Select the “Table of Contents” icon so we can tell Calibre how to automatically build a fully linkable TOC and include it in our eBook.

Since we have been using a special stye in our HTML file to manicure chapter headings, we can now use this style to tell Calibre where each chapter starts.

All we have to do is enter

//h:p[re:test(@class, "chapter", "i")]

in the field for the “Level 1 TOC (XPath Expression)”. It tells Calibre to look for all instances where the style “chapter” is applied and add them to the table of contents. Calibre will automatically use the entire chapter heading text to display in the TOC, which means the entire block of text that is style with the “chapter” style. From my experience that is exactly what we want. If not, you could narrow the selection down further using XPath expressions to drill down further. If you want to learn more about XPath expressions, feel free to check here.

The last step before we build our book is found in the “EPUB Output” section. Select the icon in the left toolbar and you will find a checkbox entry that says “Preserve cover aspect ratio.” Make sure to select this as otherwise your cover will be disproportionally scaled to fill the entire display of any eBook reader. I am not sure why this is not checked by default, but so be it.

That’s it. Click on the “OK” button and you will notice that Calibre is doing some work in the background. It will tell you so with a small animation in the lower right hand corner of the Calibre window.

This will take a second or two, depending on your computer’s speed and the length of your book. But once it is done we are ready to save the finished eBook.

Click on the “Save to disk” icon in the top toolbar and select a location where you want the book to be saved.

Now it is time to take a look how things turned out – it is the big moment. While it is possible in to use Calibre’s viewer, I found that despite the overall quality of Calibre, the viewer is – at the time of this writing – not at all representative for what your eBook really looks and behaves like on a real reader.

For first checks I always use the software versions of the Kindle or the Nook reader or Adobe Digital Editions. These will immediately give you the results you’re looking for, especially since many people use these application to actually read their books on. However, you should always make sure to also load you books onto the actual devices, if possible, to see they behave properly. It is always better to make sure than to make assumptions and extrapolate from a software implementation running on a desktop computer.
When I load an eBook up for the first time, there are usually three things I checked first.

Does the cover display correctly?

Are there proper page breaks before chapters, and do the chapter headings display properly?

Does the book contain a complete and working table of contents?

Once you have made sure these are in order, you should begin to browse the book very carefully from beginning to end. Look particularly for passages where text switches suddenly to italic text. Particularly when have inserted the <i> tags by hand, it can happen all too easily that you accidentally forgot to close the tag properly, or you mistyped it. Only a visual inspection of the book, page by page, will make sure your text is in order, so take a few minutes and go through it.

If there are errors in your source file you will have to go back and edit the HTML file. What is important is that once you have made the changes, you will have to re-import the HTML file back into the Calibre book. In order to do this, click on the “View metadata” button again to bring up the meta data input form.

You will see that the box saying “Available formats” now also includes an EPUB entry. Delete all the entries here, MOBI, EPUB and most importantly the ZIP entry. Simply select them and hit the “Delete” key on your keyboard to get rid of them.

All we have to do now is bring the HTML file back by clicking on the icon with the red book and the plus sign in the right hand corner. Select your corrected HTML file and then go ahead and rebuild your eBook file. Save it and check to make sure the errors have gone.

Once you have confirmed that everything is as it should, it is time to build the other formats. Select MOBI from the drop-down menu in the “Covert books” form. chances are you will not have to change anything else, as the structure and TOC settings format independent, and because MOBI does not require any format specific adjustments. Build the eBook and save it.

Congratulations, you now have proper EPUB and MOBI ebook versions of your book that are virtually guaranteed to be free of the most common formatting errors found in today’s eBooks. To distribute your eBooks, all you need to do is send the .epub or .mobi file to your customers via email, or to upload them to Amazon, Barnes&Noble, or whichever outlet you want to serve. In case you were wondering, the eBook files contain all the graphics and images that are needed, so you will not have to send the JPG images with it. They are safely embedded directly in the files so that they can’t get lost.

I hope I have been able to help you with this series to understand that in order to create quality eBooks it is not only necessary to tackle the problems by their roots, but also that it is not nearly as intimidating a process as one might think.

Building an eBook from the manuscript to the final build can be done well under an hour if you’re familiar with the workflow. In fact, formatting my own “Jason Dark” titles, usually takes me no more than 15 minutes.

Let me know how this series has helped you, and let me also know there are subjects and issues that you’d like discussed in more detail. I’ll definitely see what I can do and highlight these issues in follow-up posts to this series.

In addition, if you wish to hire me to create your eBooks for you, feel free to send me an email.

If you want to keep up with my eBook formatting work, don’t forget to subscribe to my Newsletter. That way I can keep you updated about the latest developments, updates to my books, code snippets, techniques and formatting tips.Also, don’t forget to check out my book Zen of eBook Formatting that is filled with tips, techniques and valuable information about the eBook formatting process.