28 thoughts on “Creating eBooks: An ePub Tutorial

  1. Hello Wasaty,

    I use Mobipocket Creator as well. Just for Mobipocket books, though; it can’t generate ePub.

    It’s the magic of Crossover for Mac that lets me run that Windows app.

    And addendum: Most of the time I spend creating an ebook, whether I’m going to produce ePub, Mobipocket Creator, or something else, I spend in the neighborhood of 90% of my time fiddling with formatting and breaking up files, adding captions to images, etc.

  2. It’s required to have a ‘toc’ attribute on the spine element. The value of this element should be the ID of the NCX file.

    See here in the spec:


    “If a Publication includes an NCX, the item that describes the NCX must be referenced by the spine toc attribute.”

    epubcheck doesn’t currently complain about it, but it should — there’s an error in the official OPF schema. This is in the process of being corrected.

  3. Hi Liza,

    Thanks for the heads up! I’ve updated the basic metadata.opf section as well as the sample epub file.

  4. Actually for dc:creator it should be “firstname lastname” and you can use the opf:file-as attribute on dc:creator to set “lastname, firstname”. You can also use an opf:role value on the dc:creator property.

  5. Wow. This is pretty complex. Even starting with text in ASCII format. Taking scans off the printed page would just be a beast to tackle!

    Great job on your tutorial. Thanks for taking the time to create and post it!


  6. Hi ,

    I downloaded few epub books from “http://www.epubbooks.com/books” ,
    when i renamed the .epub extension to .zip and tried to unzip them,
    then they are not getting unzipped ,

    What might be the problem ?

    any suggestion is welcomed.


  7. Hello Biranchi,

    I don’t know what the problem could be. File corruption, maybe, but I’m not sure.

    Sorry I can’t be of more help. :(

  8. Some things that I had to scratch my head over –

    Does the mime type need a newline after it?

    In META-INF/container.xml, I think but am not sure that full-path is relative to the root of the distro, so there’s an implied META-INF/.. . For example, the following is the correct full path for the metadata.opf in the parent of META-info:

    Are these two IDs the same?
    metadata.opf: foo

  9. Hello Lucas!

    There’s a newline at the end of the mime type for the books I’ve created, but I don’t know if it’s necessary or not.

    Yup, the full-path is indeed relative to the root of the distro.

    I’m not sure which IDs you’re referring to?

  10. I tried out MIMETYPE with and without a newline and epubcheck didn’t complain either way. I tested a no -newline version on Adobe’s reader it opened fine.

    For full-path I tested with ./ as a prefix and found that epubcheck couldn’t process it, even though it’s legal.

    The IDs got munged up during posting because I included XML. The question is what the difference is between dc:identifier in the .opf file and meta name=”dtb:uid” in toc.ncx.

  11. Lucas,

    Epubcheck isn’t infallible unfortunately, and has bugs. It’s a google code project, and so people can file bugs/ask questions.

    I don’t know what the difference between dc:identifier and dtb:uid, but it’s probably a good idea to make them match up. Different reader implementations will latch onto one or the other to ID texts.

  12. I would like to make ePub books with custom content, including video on some pages. Is there a tutorial for creating that?

    Could I make books directly in some ePub software, or would I always need to convert using this tutorial?

    Most importantly, could I make ebooks that do the cool page turning thing on my iPad?

  13. Eric,

    You should probably look at Sigil.

    “Page turning thing” is a feature of the ebook reader, not the ebook itself.

  14. Have you written any scripts that do this automatically with xslt or perl? I’m in the process of writing a DITA to ePub transformation. I’ve seen other examples that use XPointers. I was wondering if you messed with XPointer references dynamically.

  15. It’s not going to be complicated; it just contains the single line:


    It should have no suffix at all (e.g., it should just be called “mimetype”, not “mimetype.txt”) nor extra spacing or empty lines.

  16. this is an awesome tutorial, thanks for that…

    how to link them within the file, for example if i want to link a table of chapter 2 from chapter 1, is that a normal html method or should i need to do something different in epub?

  17. Thank you so much for this tutorial. It has been a life saver, after weeks battling with my .epub conversion. You clearly put a lot of work into it. There are hardly any other places (at least that I can find with google) that go into such detail. Thanks!

Comments are closed.