HOWTO: Create a usable ePub file for Lulu.com
I’ve been having a lot of problems with getting my latest ebook uploaded to Lulu, and I know other people have had similar problems, so here’s what I’ve learned so far. (Currently I’ve *finally* got to the point where they’ve accepted my ePub file, but then the next screen gets me an ‘unrecoverable error’).
I’m assuming, first of all, that like me you’ve created your book in a WYSIWYG word processor (like Microsoft Office or AbiWord or LibreOffice) rather than having it already in some suitable XML-like format or creating it in LaTeX or something. If you know enough to do those things, you know enough to hand-hack an ePub file anyway.
But if you have your book as an .odt , .pdf , .rtf or .doc file, you’ll want to convert it and preserve most of your formatting. The best software to do this is a Free Software package called Calibre, available for download for Windows, Mac and GNU/Linux here (though if you have GNU/Linux on your machine it’s almost certainly in the repos of your distro, and you should get it from there).
However, Calibre has what seems to me a rather unintuitive interface full of giant blobby teletubby icons. If you have any difficulty using it, you might want to use this site, which is just a web front-end to Calibre. I have no idea what, if anything, they do with your file once it’s uploaded, so the usual caveats about ‘cloud’ services apply, but I can confirm that the ePub files they generate are valid ones, and generated with a recent version of Calibre (0.7.40 – for comparison the version in Debian Squeeze is 0.7.38 while in Sid it’s 0.7.42).
When you have your ePub, you can check that it’s basically valid using this online validator. However, you can still run into several problems.
The first one I found was a Permissions problem. An ePub is just a renamed .zip file, containing lots of other files which make up your book, and Calibre appears not to give anyone else the permission to do stuff with those files.
The second one – and one that a lot of people have complained about – is unmanifested files. This problem, which is not explained properly by Lulu, is a simple one – in the .zip file, there’s a list of all the files that should be there ( this list is called content.opf ). Sometimes there are extra files in there that shouldn’t be – in my case Calibre generated a directory called META-INF but didn’t list it in content.opf .
So here’s what you need to do. Take the ePub file, and extract it (Windows users can do this by renaming yourbook.epub to yourbook.zip and using an app like Winzip. GNU/Linux users and users of other unixalikes can use the unzip command).
Next, change the permissions of all the resulting files so that everyone can access them. Here’s how to do that in Windows. In GNU/Linux you just run the command chmod -R 777 * (making sure, of course, that the directory you’re in contains only those files that you wish to alter).
Now, open the file content.opt in a text editor (like Notepad, Gedit or Vim). You should see in there a section like:
<item href=”Pictures/10000000000000CC000000A83F7DB793.jpg” id=”id3″ media-type=”image/jpeg”/>
<item href=”Pictures/100000000000012C000001C881668E50.jpg” id=”id5″ media-type=”image/jpeg”/>
<item href=”Pictures/1000000000000177000001781C2F2F04.jpg” id=”id8″ media-type=”image/jpeg”/>
<item href=”Pictures/10000000000001A2000001837F27C3DA.jpg” id=”id4″ media-type=”image/jpeg”/>
<item href=”Pictures/10000000000002BC000000E20000658C.jpg” id=”id2″ media-type=”image/jpeg”/>
<item href=”Pictures/10000000000003CF000002FA25F145A0.jpg” id=”id7″ media-type=”image/jpeg”/>
<item href=”Pictures/10000000000003F9000001D7FD934D20.jpg” id=”id6″ media-type=”image/jpeg”/>
<item href=”index_split_000.xhtml” id=”id129″ media-type=”application/xhtml+xml”/>
<item href=”index_split_001.xhtml” id=”id128″ media-type=”application/xhtml+xml”/>
This is the list of files that should be in there. Look through that list and compare it to the files you’ve got, and delete any files that aren’t in the list. If you have anything that isn’t in this list, Lulu will (quite rightly) reject it – you could have put anything in there along with your book, after all.
Now, you’ve got your list of files sorted out, and they all have the correct permissions. What you need to do now is create a new zip file with all of these in. But it’s not *quite* that simple – you have to make sure the file called ‘mimetype’ is the *first* file in the zip file, and normally when you create a zip file the files in it are listed either alphabetically or by time added.
So what you need to do is create a new file and *only* add the file ‘mimetype’ to it. In Windows you can create a zip file called mybook.zip using Winzip and add this file. In GNU/Linux, use the command zip -X0 mybook.epub mimetype .
Now, once you have this file, you can add the rest of your files. In Windows, you can use Winzip for this. In GNU/Linux, use the command zip -X9Dr mybook.epub [list of files and directories] .
If you’ve done this in Windows, you must now rename your file from mybook.zip to mybook.epub . Check your file in your favourite ebook reader (if you don’t have one, you can read files in Calibre as well as write them) and make sure it looks more-or-less like you want it to. Then check you’ve got everything right with this online validator and you can upload it to Lulu. If everything’s gone right, then this should be everything you need to do to get your book uploaded – assuming you don’t, like me, then get a server problem on Lulu’s end.