Thursday, January 31, 2013

Kindle Fixed Layout Tutorial - Part 3



The two companion templates are provided both in their final Kindle format as well as in epub format, the current standard on which all ebooks are based (with many proprietary modifications by Amazon, Apple, and Barnes & Noble), and which will form the basis of the file you will build before converting it to the final compiled mobi format for upload to Amazon or your own device. Kindle files cannot be built directly, but must be converted from a "source" file; nor can they be opened for editing directly, but must first be extracted and converted back to epub. In addition, while Amazon accepts Word docs and HTML files into its Kindle Digital Publishing (KDP) ingestion system, epub is the only source that supports fixed layout content, and thus, the only one that concerns us here.

Both templates are available for free to those who purchase my complete ebook tutorial, "How To Make Kindle Comics & Children's Books," but are also available to purchase separately for a minimal fee from the links above.

The epub version of the templates will allow you to view the source code referenced in this tutorial, and to replace the template's contents with your own. This tutorial provides step-by-step instructions on how to do just that.

In addition to the templates, a number of additional resources will either be required, or come in handy as you set to work creating your masterpiece.


1. Text Editor

Even if your book consists entirely of images, you will still need a good text editor capable of creating clean, plain text files (i.e. not rich text) for inserting formatting data into a handful of required support files. Preferably it should have numbered lines, as this will aid in editing more complex files. I prefer Notepad++ on the PC, while TextWrangler for the Mac is a highly popular free text editor. If you use the default PC or Mac text editor be sure to turn off Rich Text and save your files as plain text. A good web building program such as Dreamweaver is almost overkill for building ebooks, but will certainly do the job. For reasons to be mentioned shortly, I prefer a program that opens quickly, unlike the slower loading Adobe software.

A Note on InDesign: Adobe's premiere layout software will export to epub, but it also inserts a lot of extraneous code into the files that make it more complex than necessary to edit, requiring a lot of "clean-up" that is often more work than creating a file from scratch. This tutorial will not attempt to explain everything you'll need to remove from your epub file in such cases, but only what you need to put into it. Once you've learned that, you'll be more readily able to clean up an InDesign exported epub.

Additionally, Amazon offers an InDesign plug-in for export directly to Mobi, but this does not yet fully support fixed-layout features such as region zoom. Consequently, I do not cover InDesign exports in this tutorial. However, the files produced can be edited using the instructions contained here.

2. Image Editor

Images in Kindle ebooks need be correctly formatted both for pixel resolution as well as file size. Thus, you will need an image editor like Photoshop or the Gimp that can resize images and accurately compress them into JPEGs. In Photoshop, using the "Save for Web" option gives you greater control over the final file size, with several options for retaining the highest quality at the optimal compression level. Image size will be discussed in further detail later in the tutorial.

3. File Compressor / De-Compressor

An epub file is really just a zip package with its extension changed. You can manually change the .epub extension to .zip in order to extract the files inside and add new ones (be sure to change your file browser settings to show extensions so that you can edit them). However, some programs, such as 7-Zip, allow you to modify the contents of an epub without changing the extension, or even extracting the files, which can save you a great deal of time. Set your preferred text editor (i.e. Notepad++) as the default in 7-Zip (Tools > Options > Editor) so that you can simply right-click on a file from within the epub archive and select "Edit" to open and modify the file without extracting it. You can also drag and drop new files into the archive, or delete ones that are already in there.


1. Kindlegen

As mentioned, Amazon provides a free conversion tool called Kindlegen that can produce a final Kindle compliant file that can be uploaded to KDP or distributed to Kindle customers as you see fit. This is a command line tool that is simple to use, accepts epub input (as well as X/HTML), and supports all the features of KF8. Although it may appear complex at first, it is really very simple, and its use will be fully explained in this tutorial. It is available for Windows and Mac, as well as Linux.

A Note on Calibre: Many ebook creators rely heavily on a readily available (and often updated) free software package called Calibre, created by Kovid Goyal. While Calibre is a fabulous program, both for ebook conversion and organizing your digital library, it does not fully support fixed layout formats, due to their complexity and the proprietary nature of some included code, which will not work in other formats. Do not attempt to use it to produce fixed layout ebooks in Kindle format.

2. Kindle Previewer

Another free tool offered by Amazon is this graphical interface, intended (as the name suggests) for previewing your Kindle file before uploading to KDP. However, it also functions as an interface with Kindlegen, automatically converting epub inputs into Kindle format for previewing. Consequently, some prefer to use it for this purpose rather that accessing Kindlegen directly.

Kindle Previewer is supposed to function as an emulator, allowing those who do not own a particular Kindle app or model to see how their ebook will display on any given Kindle reader. Since few authors can afford to purchase every device available, this can be quite useful. Unfortunately, the previewer has been plagued with bugs and is notorious for not displaying content accurately. It's better than not having any idea at all, but I recommend the real thing whenever possible. If you intend to produce a professional quality Kindle ebook for sale to the public, it is incumbent upon you to acquire at least one current Kindle device on which to test your product for quality assurance purposes.
1. Mobi Unpack

In some instances it may be useful to know what's happening inside your Kindle file after it's been converted (to see how much your images have been compressed by Kindlegen, for example, or to see what code is being added or altered). As mentioned, standard un-zip software will not suffice, as the final Kindle file is no longer just a zip archive with a different extension, and therefore cannot be extracted in the usual way. For this purpose Mobi Unpack will be required. This is a python script (and thus requires Python to be installed), that creates a decompiled archive of a Kindle file's contents, allowing you to see what changes Kindlegen has made. This is not required for this tutorial, but its use and purpose will be discussed here to some degree, along with a few of the more interesting results you may find.

2. KindleStrip

The file created by Kindlegen will always be much larger than the source files from which it was created. This is because the final file will include both a KF8 formatted version of your ebook as well as a reflowable Mobi7 version for backwards compatibility with older devices that do not support KF8 fixed layouts. In addition, the original source files are also included in the final .mobi package as a zipped archive, just in case Amazon needs them for re-converting later. However, only the portion relevant to a customer's device will be downloaded from Amazon to their e-reader, so the actual file size delivered will be smaller than the one created. You may want to "strip" the file in this manner yourself for selling elsewhere, such as on your own website, or through other retailers. KindleStrip is another python script that fulfills this function.

NOTE: Both of the above are complex programs and procedures intended for advanced users only. I provide them purely for your information, and do not cover their use in this tutorial, nor are they required to proceed. The links provided lead to Wiki pages that detail their use and offer further resources.

1. Kindle Publishing Guidelines

If you haven't already visited the Kindle Format 8 page at Amazon it would behoove you to do so, as it is the central hub for all things KF8, containing links and information about the format. Along with a FAQ and forum, the primary resource is the Kindle Publishing Guidelines, a pdf document containing all the details Amazon has disclosed concerning Kindle ebook code thus far. Sadly, there is both a wealth and scarcity of useful data, in unequal measure, some of which is contradictory and some just poorly written, none of which is thorough, although much is critical to know. You'll get the necessary portions here, but I recommend you also read the official guidelines when you find the time. They will make more sense once you have worked through this tutorial.

2. Samples

While you're hanging out at Amazon be sure to download the free ebook samples they link to on the KF8 page. These include both reflowable and fixed layout samples, each of which can be downloaded separately, or all together in a zip file from the "Samples" link. These contain both compiled Kindle formats of the ebooks as well as all their source content, including some informative notes within the code. At present, however, they are somewhat out of date, although they have occasionally been updated. The examples are instructive, if not always clearly explained. There is nothing in them that you will not learn more clearly in this tutorial, and much is missing that is given in great detail here.

3. Further Resources

As with most things, the Internet is filled with facts and fancies regarding ebook formatting, some insightful, much confusing, and most awash with errors. There are none that I know of regarding the KF8 fixed layout format specifically that are worth visiting, although there is a great deal of information to be found concerning the ePub standard upon which Mobi files are based. A few stand out for their clarity or wealth of content, and the primary ones among these are listed here for your reference.

Supported HTML5 / CSS3 tags - An Amazon page that lists the major elements supported in KF8. Though not exhaustive, these are more than most authors will ever need. The list is also included as an Appendix in the Kindle Publishing Guidelines.

International Digital Publishing Forum (IDPF) - Central hub of the committee tasked with developing and maintaining the ePub spec, on which all major ebook formats are based, including KF8. Because of this it is useful to know the actual code and its parameters.

MobileRead Wiki - A platform for the discussion and dissemination of information concerning ePub code and file structure, including many sample files created to test out various elements that you can download.

A number of other specific resources will be mentioned at the points where they are relevant. In addition, a number of other resources are listed and linked to in the ebook.


The definitive guide to the Kindle fixed layout format, this fully revised and expanded tutorial will take you line-by-line through two working templates, including both the content and support files, as well as all layout and functionality features, explaining in painstaking detail what each element is for, and what your options are in every instance. Also included in the ebook is a code to download both templates for free!
Add to Cart

Kindle .mobi format
+PDF Edition