Chapter 6
Converting EPUB Files
image    Understand how to convert from EPUB to other formats
image    Learn how to convert from other formats to EPUB
image
The majority of reading devices and systems support EPUB. Unfortunately, not all systems support EPUB and not all formats are EPUB compatible. EPUB is usually an easier format to manipulate, so being able to convert other formats to EPUB helps. The opposite is true as well. If you need another format, EPUB is easier to manipulate and convert to the other format.
Not all conversions are 100 percent perfect. Some need a little tweaking, but with all the information from the previous chapters, it should be simple.
Getting Ready to Convert
For this chapter, you’ll need Calibre. Calibre is an e-book manager. It lets you organize the books into categories and series. The main thing about Calibre is its ability to convert files.
A list of input formats is shown in Table 6-1, and the output formats are in Table 6-2.
image
Table 6-1   Calibre Input Formats
image
Table 6-2   Calibre Output Formats
In most cases, a format from the input list can be converted to the output format. However, a problem may arise if any security is enabled on the input (see Chapter 7).
Once a book has been converted, it may be necessary to review the output file. Sometimes certain items may not convert as desired. Some formatting may be changed or lost.
A good example is converting from PDF, which does not store the information about paragraph starting and ending points. Because of this, some paragraphs are not output as complete paragraphs. Sometimes the paragraphs are joined with others or split up into multiple paragraphs.
Converting to EPUB
Start Calibre after you install it. E-book files can then be dragged and dropped onto the window, or click Add Books on the tool menu. Once files are added, you will see them listed in the Book List pane. If you select a book from the list, the right pane shows the cover (if it exists), the author, the file formats, and a hyperlink to the file path.
An example is shown in Figure 6-1 showing Calibre with the information for Rumpelstiltskin to the right.
image
image
Figure 6-1   Calibre screen showing Rumpelstiltskin
Now, download The Three Musketeers from www.ManyBooks.net, but download it in the FictionBook2 (fb2) format. Add the new file to Calibre and select it. To the right, you should see the format listed as FB2. With the book selected, click Convert Books from the toolbar. A new window should appear as shown in Figure 6-2.
image
image
Figure 6-2   Converting in Calibre
NOTE
image
If you open the FB2 file in an editor, you can see it is an XML file similar to XHTML. There are no header tags, only paragraph tags.
In the upper-right corner of the Conversion box, the output format needs to be EPUB.
The only suggestions I can make here is to change the following:
image    Look & Feel   Clear the UnSmarten Punctuation box. This removes the slanted quotation marks and the like, making them regular quotes.
image    Page Setup   Select your EPUB device from the output profile. This assures your EPUB is more suited for your device.
Make other adjustments based on your preference. I mainly “unsmarten” the punctuation so it is easier to search in Sigil. The “smartened” quotes are not the same ones on the keyboard.
Select the OK button in the bottom-right corner. The main screen should reappear showing Jobs: 1 in the lower-right corner. Once this is done, you should have EPUB listed next to the format for Three Musketeers.
NOTE
image
Be aware that some conversions may take a long time to complete. If you single-click the Jobs: area, a new window will appear displaying the progress of any running jobs.
Keep in mind that the file formats are stored in the Calibre Library directory. To save a copy at a different location, right-click the format you wish to save. So, right-click the EPUB link on the format line for The Three Musketeers. Select Save The EPUB Format To Disk. Choose where you want to save it, and select OK. Now you can go to the location where the file was saved and open it in Sigil.
If you look at the CSS style sheet, you should see the styles are usually called “calibre” with a number following it. When you see the calibre styles, you know it has been converted with Calibre.
The best thing to do at this point is to clean up the EPUB as best as you can. Hardly any conversion is 100 percent exact.
Now, you may be thinking that it would have been easier just to download the EPUB version. In this case, that would be true. Sometimes, however, you may come across a book that is not in the format you need it in. You’ll need to perform a conversion and usually tidy it up a bit.
Let’s try another one. Download the MOBI version of The Island of Doctor Moreau by H.G. Wells. Perform the same steps as when you converted The Three Musketeers. Once it has been converted to an EPUB, open it in Sigil.
Now begins the work. I start by separating the chapters into individual XHTML files and naming them appropriately. Make sure the chapter titles are header <h2> tags. Modify the cover page as needed, and set up a title page. If there is a legal section for Gutenberg, set it aside in its own XHTML file. Do not forget to check the Metadata Editor (press f8) and make any changes.
I usually also remove all styles and start over. Before you remove styles, make sure there are no special italics and bold styles, or the like.
NOTE
image
Be aware that most e-books are usually from Project Gutenberg. Because of this, most formatting is nonexistent unless someone has added it. It may take a little time to enhance the look, but in the end you’ll have a nice book for your collection. Also, the more of these you do, the easier it gets. You can get some files from Gutenberg that have formatting in them, especially if they are EPUB or Kindle formats.
Special formatting tags may be used in the standard text files to signify italics. For example, some texts may enclose words in forward slashes (/), “He ran /fast/.” should appear as “He ran fast.” Other e-books may have words which should be italicized in all caps.
Take a look at c06-01.epub (located at www.mhprofessional.com/EPUB) and you’ll find an example of The Island of Doctor Moreau converted from the MOBI format to EPUB and slightly enhanced. This version was downloaded from www.Gutenberg.org.
You may need a little practice, but the process gets easier the more you convert and enhance the EPUB files.
Converting from EPUB
You may recall that back in Chapter 1 I made reference to the Amazon Kindle. Well, here we are. Sometimes it is easier to manipulate a file as an EPUB and convert it to the Kindle format (AZW, MOBI).
Other formats are available, as you have seen in Table 6-2. It seems that from the list, the Kindle format would be the most popular to convert from EPUB.
NOTE
image
Keep in mind that most MOBI and AZW files can usually have the extension changed to the other without any problems. The difference is that Amazon uses a different security than MOBI. So a secured AZW file is different from a secured MOBI file. AZW files have a few enhancements over MOBI, such as compression, etc.
The process of converting from EPUB is the same as when converting to EPUB. Right-click an e-book in Calibre, select Convert, and change the output format to AZW3.
Before you start, be aware that the cover image used for the new e-book is the same one shown on the right side of the Calibre screen when you select an e-book. If the image is already in the e-book you are converting from, it will now be in the new e-book twice. To fix this issue, right-click the cover image on the right side of the screen and select Remove Cover. You only need to worry about this for covers of the e-books you will convert. You can get a new book cover image by selecting a book and clicking the Edit Metadata icon. When a new window opens, click Download Cover. Of course, you’ll need to be connected to the Internet. After some time, you should be shown covers. Choose the cover you like and select OK.
TIP
image
To edit any files in Calibre, right-click the file in the book list and select Open Containing Folder. Once the folder opens, select the file type you want to edit and open it in your editor.
The sample file c06-02.epub is an EPUB file of “Rikki-Tikki-Tavi” taken from Rudyard Kipling’s The Jungle Book. The sample files c06-03.azw3 and c6-03.mobi show the EPUB files converted to the Kindle format following the steps previously mentioned.
To convert EPUB to Kindle KF8 (AZW3), you can also use KindleGen and Kindle Previewer.
The Kindle Previewer application allows you to emulate the Kindle display on various Kindle devices: Kindle Paperwhite, Kindle, Kindle DX, Kindle Fire, Kindle Fire HD, and the Kindle Fire HD 8.9". You can also emulate the Kindle App for iOS for the iPad and iPhone.
Since there is a slight difference in the MOBI and AZW formats, Calibre supports two different types of MOBI. The “old” MOBI is the MOBI version 6 format before AZW. A “new” MOBI format is technically AZW3 (KF8). Table 6-3 shows the various Kindles and the format support. A third MOBI option is listed as “Both,” which contains both the old and new formats in one file. The new format will be used unless not supported, and the old format is a fallback.
image
Table 6-3   Kindle Format Support
The sample files for c06-03.mobi are split up as c06-03-old.mobi for the MOBI 6 format. The c06-03-both.mobi file contains both old and new styles, while the c06-03-new.mobi is the KF8 format. All of these can be tested on a Kindle device if you have one; otherwise, use the Kindle Previewer.
Converting to MOBI is the same as converting to AZW3, except for one small difference. When using Calibre to convert to MOBI, there is a screen called MOBI Output, as shown in Figure 6-3.
image
image
Figure 6-3   Calibre MOBI output
The following figures show various outputs for “Rikki-Tikki-Tavi.” Figure 6-4 is a screenshot from a Barnes and Noble Nook (first edition), and Figure 6-5 is a second-edition device.
image
image
Figure 6-4   Nook first edition
image
image
Figure 6-5   Nook second edition
The Nook first edition shows embedded fonts, while the second edition does not. As you will see, the same is true of the Kindle devices. The Nook HD devices show embedded fonts as well.
For the Kindle, Figure 6-6 shows the Kindle Paperwhite, Figure 6-7 is the Kindle, the Kindle DX is in Figure 6-8, and the Kindle Fire is shown in Figure 6-9. The Kindle images are from the Kindle Previewer using MOBI 6 and AZW (“Both”).
image
image
Figure 6-6   Kindle Paperwhite
image
image
Figure 6-7   Kindle
image
image
Figure 6-8   Kindle DX
image
image
Figure 6-9   Kindle HD
You can see that the images are similar for the Paperwhite, Kindle, and DX. The embedded fonts are not available on these devices, even if you use an AZW format. The Kindle HD devices all look similar as well.
Practice, Practice, Practice
I cannot emphasize enough how easy the process can get with practice. Converting files is a simple task, but enhancing the e-books takes a little time. It gets easier the more you do it. The XHTML and CSS code become easier. It even helps to have a “standard” CSS file that contains the regular styles you use most of the time. Simply add the CSS and link the files to it.
You may also be thinking that many conversion applications are available on the Internet, so why not use them? Since Calibre can convert to so many formats, I used it as an example. If you are more comfortable with another application, by all means, use it. There are other EPUB editors than Sigil, but again, I used it as an example. Use the applications you are comfortable with.
Most e-books can be converted and enhanced in a very short time. Others may take a very long time. For example, Grimm’s Fairytales or Household Tales has over 200 short stories and takes a long time to split into separate files. With practice, however, it won’t take long for you to create your own library for your reading device.