Ebook / e-PUB tips

kindle logoI’ve been playing around with the epub format. Basically, an epub file is a zip file… with a few catches. Since it’s good to have a bit of a clue, here’s two catches I stumbled across — the hard way.

Catch 1: mimetypes

You need structure.
The first entry in your .epub file must be the “mimetypes” file. You just need it. Steal it from any other epub file — that’s easy :)
However, the file must be stored in a very precise manner in the zip file. For one, it may not be zipped. Le argh? Annoyance. Anyway, this works to create a fresh file:
zip -0X ../my-new-epub-file.epub mimetype
Where “-0″ ensures “store, not compress” and the “X” strips any

Next, you need a directory structure (META-INF/, OEBPS, cover.jpg, etc.). Again, open any existing .epub file and build your source in that fashion. Not too hard.
Now, to add all your goodies (once you’re done):
zip -Xr9D ../my-new-epub-file .epub *
r for recursive add, 9 for extreme compression.

Catch 2: HTML entities

Most & character codes are not allowed. Le crap.
Simplest solution: get rid of them. You can try using &#### codes, but there’s no real guarantee it works on devices. Alternatively, you just type the character in your favourite editor straight in the source and ignore that feeling in your gut about decent character encoding.

Comments are closed.