Pages

Wednesday, August 28, 2013

EPUB STUFF - PART TWO

Continuing the saga of ePub creation. Here's the ePub version of toc.ncx:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
   
<ncx version="2005-1" xml:lang="en" xmlns="http://www.daisy.org/z3986/2005/ncx/">
   
<head>
<meta name="dtb:uid" content="268a4670-ca8a-11e2-8b8b-0800200c9a66" />
<meta name="dtb:depth" content="1" />
<meta name="dtb:totalPageCount" content="0" />
<meta name="dtb:maxPageNumber" content="0" />
</head>

<docTitle>
<text>Your Title</text>
</docTitle>

<docAuthor>
<text>Lastname, Firstname</text>
</docAuthor>

<navMap>

<navPoint id="cp" playOrder="1">
<navLabel><text>Cover</text></navLabel>
<content src="cover_page.xhtml" />
</navPoint>

<navPoint id="tp" playOrder="2">
<navLabel><text>Title Page</text></navLabel>
<content src="title_page.xhtml" />
</navPoint>

<navPoint id="copy" playOrder="3">
<navLabel><text>Copyright Page</text></navLabel>
<content src="copyright.xhtml" />
</navPoint>

<navPoint id="c1" playOrder="4">
<navLabel><text>Chapter 1</text></navLabel>
<content src="chap_1.xhtml" />
</navPoint>

<navPoint id="c2" playOrder="5">
<navLabel><text>Chapter 2</text></navLabel>
<content src="chap_2.xhtml" />
</navPoint>

<navPoint id="c3" playOrder="6">
<navLabel><text>Chapter 3</text></navLabel>
<content src="chap_3.xhtml" />
</navPoint>

<navPoint id="c4" playOrder="7">
<navLabel><text>Chapter 4</text></navLabel>
<content src="chap_4.xhtml" />
</navPoint>

<navPoint id="about" playOrder="8">
<navLabel><text>About the Author</text></navLabel>
<content src="about.xhtml" />
</navPoint>

</navMap>

</ncx>


Copy and paste it into Notepad++. Save a copy in your ePub Making Kit folder before modifying it for the current book.

It would probably be a good idea to get a different identifier number for the ePub edition of your book. You can go back to www.famkruithof.net/uuid/uuidgen and get more than a hundred at a time. Keep a text file with UUID numbers in your book making kit folders; update the list by ticking off the numbers used (saying for what book, what edition, and so forth).

But here’s a tumbling block: Depending on your use of the ePub file, you might now have to get an ISBN from somebody. I believe some distributors (like Smashwords) supply a number for free. You need to look into it.

The first “playOrder” item is the book’s cover. That’s a change. The href is to cover_page.xhtml, the file that contains the tag for the cover image.

After that comes the title page, the copyright page, the chapters (listed one by one, just as in the Kindle ncx file), and ends with the About the Author page. What’s missing is the HTML Table of Contents. That file isn’t strictly necessary for ePub.

Add listings for all your chapters. Save the modified copy of the ncx file in the same folder you've been using to collect your other book parts. If you added navPoints for new chapters, you will probably want to save these changes before closing the template.

Next, the content.opf template:

<?xml version="1.0"?>
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">

<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title>Your Title</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="BookId" opf:scheme="UUID">268a4670-ca8a-11e2-8b8b-0800200c9a66</dc:identifier>>
<dc:creator opf:file-as="Lastname, Firstname" opf:role="aut">Your Name</dc:creator>
<dc:publisher>Fake-out Publications</dc:publisher>
<dc:date>YYYY-MM-DD</dc:date>
<dc:subject>Type of book</dc:subject>
<dc:description>Say a few words about your book.</dc:description>
<meta name="cover" content="cover" />
</metadata>

<manifest>
<item id="cover_page" href="cover_page.xhtml" media-type="application/xhtml+xml" />
<item id="title_page" href="title_page.xhtml" media-type="application/xhtml+xml" />
<item id="copyright" href="copyright.xhtml" media-type="application/xhtml+xml" />
<item id="chap1" href="chap_1.xhtml" media-type="application/xhtml+xml" />
<item id="chap2" href="chap_2.xhtml" media-type="application/xhtml+xml" />
<item id="chap3" href="chap_3.xhtml" media-type="application/xhtml+xml" />
<item id="chap4" href="chap_4.xhtml" media-type="application/xhtml+xml" />
<item id="about" href="about.xhtml" media-type="application/xhtml+xml" />
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
<item id="stylesheet" href="style.css" media-type="text/css" />
<item id="cover" href="cover.jpg" media-type="image/jpeg" />
<item id="title" href="title_page.jpg" media-type="image/jpeg" />
<item id="chap1_start" href="cs-1.jpg" media-type="image/jpeg" />
<item id="chap2_start" href="cs-2.jpg" media-type="image/jpeg" />
<item id="chap3_start" href="cs-3.jpg" media-type="image/jpeg" />
<item id="chap4_start" href="cs-4.jpg" media-type="image/jpeg" />
</manifest>

<spine toc="ncx">
<itemref idref="cover_page" />
<itemref idref="title_page" />
<itemref idref="copyright" />
<itemref idref="chap1" />
<itemref idref="chap2" />
<itemref idref="chap3" />
<itemref idref="chap4" />
<itemref idref="about" />
</spine>

</package>


You’ll find it’s a lot longer, but should be pretty familiar. Save a copy in your ePub Making Kit before making changes.

Modify the Dublin Core for the current book, including the new identifier number. If you’re now using an ISBN in that section, change the “opf:scheme” from UUID to ISBN.

You’ll see the cover listed at the end of the <meta> section, just like before:

<meta name="cover" content="cover" />

It’s also listed in the second half of the <manifest> section, but this time it’s heading up a list of other images: title page and chapter-starts. Delete mention of any images you’re not actually using.

In Kindle you could use jpg, pgn, gif, or bmp images inside the book; in ePub it’s jpg, png, gif, or svg (scalable vector graphics).

There are listings here for just four chapters (with chapter-start image support built in). The version in the Templates section goes to twenty. Add or subtract as needed.

But remember, everything in your book (except the mimetype file and the META-INF folder) needs to be listed in the <manifest>. Otherwise, it won’t pass the validator.

You don’t really need an XHTML TOC in your book, since most e-readers create one from your ncx file. But if you want to add one anyway, just in case, here’s how: Grab the core info from your HTML TOC—from the beginning of the Title header code to the end of the </div> tag—and drop it into one of your book chunk templates. Probably wouldn’t hurt to save this file as a template in your ePub Making Kit.

You’ll have to add this new item to the ncx file and the opf file, naturally. For the ePub’s opf file, it’s almost the same line as in your Kindle-ready version:

<item id="toc" href="toc.xhtml" media-type="application/xhtml+xml" />

Put it somewhere in the <manifest> section. Then add this to the bottom of the <spine>, after the “about” reference:

<itemref idref="toc" />

Put the appropriate listing in your ncx file, too. Again, I suggest you add it at the end. It’s easier. Plus, if a particular e-reader does create a TOC from the navigation map, it would be good to tuck the XHTML version out of the way. The listing is the same as it was in the Kindle ncx file—just add the x in front of the “html” extension.

Your cover image can remain the Kindle-preferred jpg version, but you could have other types mixed in here (for chapter starts or whatever). Just remember to change the media-type. Except for that rascal jpg, media-types copy the image file extension name, letter for letter.

If you followed my advice and let KindleGen resize your display cover when it built your mobi file, you should load the full-size image back into GIMP and make it smaller. Depending on the final destination for this ePub, there may be different specs to follow. I’ve seen 600 x 730 for nook, but also 750 x 1100.

Using the class="wide" notation inside the <img> tag will set your images at 98%, whatever their pixel size.

In the <spine> section you’ll find listed all the relevant stuff: cover page, title page, copyright, chapters, About the Author (and maybe TOC). This is the order they’ll be assembled and listed. Remove any items you’re not using.

If you want your book to open with the cover, you need do nothing. If you’d rather see your title page jump up first, you need to modify the listing:

<itemref idref="cover" linear="no" />

The start of your book will default to the next item on the list, though “Cover” remains the number one guy on your Table of Contents. You can also add the linear="no" spec on the listings for your title page and copyright page, so your book opens on the first page of Chapter One. Up to you.

As you can see, there is no <guide> to worry about in an ePub book’s opf file.

I’m going to break with tradition and suggest you just dump all your images in the OEBPS folder. Of course, if you don’t have chapter-start images, there’s only going to be one or two images to dump there. Some ePub creator programs like to segregate all your stuff into folders: one for the text files, one for images, one for style sheets. But who’s going to see it if you just let everything flop around in one big folder? Take a break—you don’t have to tidy up for anybody.

Also, this way you won’t have to go back and add an IMAGES folder to the path for your images, or a TEXT folder path for your XHTML files, etc.

Now, at last, you’re ready to assemble the package. Open Windows Explorer and navigate to the assembly folder for your book. It should have just three items in there: the mimetype file, a META-INF folder (with “container” inside), and a fully populated OEBPS folder. Right-click on an empty part of the window to open a menu. Maneuver down the list with the cursor to “New” and another list will open. Somewhere (possibly at the bottom) is the selection called “Compressed (zipped) Folder.” Left click there to create an empty zipped folder. Name it for your new book, but keep the zip extension (for now).

Normally I use xplorer2lite for file fiddling. If you have this program, follow the above instructions, but click "Shell new" at the bottom of the menu. Inside you’ll find the same Compressed Folder selection as in Windows Explorer.

Proceed in the following order (it’s important): First, drag the mimetype to the zipped folder. I like to use the right-click drag, selecting Copy from the menu; this way I keep a copy of the files outside the zipped archive—I’ll almost certainly need to fiddle with the HTML before getting the ePub file to validate. Next, tuck the META-INF folder inside. Finally, the OEBPS folder. Now right click the zipped folder, select Rename, and change the extension from zip to epub.

And there you go: an epub version of your book. Not that bad, right?

The official ePub validation Website is run by idpf.org (International Digital Publishing Forum).The site hosts ePubCheck 3.01. You can also download a copy and run this program from your computer, but you need to have Java installed. And you have to run it from the Command Prompt. That's annoying.

I found a program called ePubChecker that runs an older version of ePubCheck (1.0.5) in a Windows GUI environment. It’s a lot easier to use. Just browse to the file you want checked and set it loose. I’ve heard a rival program (Flightcrew) has error messages that are easier to understand. But if you followed my instructions exactly, you’re probably saying, “What error messages?”

After it passes the validation process, go online and run the file through the big guy, ePubCheck 3.01.

I want to thank Aaron Demott (Yoda47) and Liza Daly for their tutorials on ePub creation.

No comments:

Post a Comment

Comments are welcome -- and moderated by me. Please be patient.