Saturday, January 7, 2012

Mobipocket's OPF File Part 1

Of the three .txt files making up the mobipocket version of my first Kindle book, River's Bend, I found the .opf file the hardest “to get right.” The .opf or open (ebook) package format has a number of sections, all different, but related, making its structure confusing. Accuracy, however, is critical.

Mobipocket Creator produced River’s Bend's original .opf file in a subfolder on my hard drive way back in November when I first hit “build” in the Creator’s publishing window. The book built with 56 warnings and three errors and it continued to produce a significant number of warnings and errors “build” after “build”. The warnings I soon associated with my chapter heads and pages containing front and back matter. Mobipocket Creator identified the errors as a missing cover and missing table of contents (the latter, no doubt, the cause of those 56 warnings). The problem (and solution) was the .opf file. Simply put, the .opf file is the glue that holds the digital book together--it’s what makes the e-reader (Kindle, Nook, ipad, whatever) work. It’s the “brain” of the digital book, and if its circuitry isn’t right, the book is screwy.

The .opf file is an .xml (eXtensible markup language) file, which, as I understand it, is a container file within which .html and .xhtml/.css (used for EPUB) languages are placed. I have no idea what else .xml files are used for, but certainly they contain .txt documents belonging to digital books, because that’s what the mobi and epub .opf files are--.txt files. Regardless, .xml is equal to, but different than the formatted text that goes into them. Think of the combo as “language within a container”--assuming you want to think about it at all. For our purpose here, you really don’t have to. Suffice it to say, the format for this file is rigid, if simple. All you have to do is get the letters, numbers, and goofy-looking characters in the right place and you can create your own .opf file from scratch.

BUT, Mobipocket Creator can create one for you based on the data you feed its publication window.  River’s Bend’s first .opf file I liken to a shell. The Creator produced a perfectly formatted header for me as well as all the sections, but a lot of needed information was missing. Further, the file was not well structured. The solution was to edit it. Given the .opf file is a .txt document, the ideal editor is Notepad++. If you don’t already have that particular software, go here for a free download.

I edited River’s Bend's .opf file from the dc:identifier down. I also broke down the sections so I could "see" them. My Mobipocket Creator-produced file ran from the left to the right side of the screen, then disappeared from view. It’s hard to work with that, and even scrolling doesn’t organize the sections so I can tell where one section/subsection ends and the next one begins. Clearly, carriage returns were needed.

The mobi .opf file consists of five sections wrapped up within a package.
The sections are:
(1) Metadata
(2) Manifest
(3) Spine
(4) Tours (unused)
(5) Guide

Over the next several weeks I intend to detail the .opf file section by section. I’ll start next week with metadata. My goal to produce a mobi book evolved into a plan to create a template whereby I could produce from scratch the files required to build a mobi book. By this, I mean, not using Mobipocket Creator to create the “files.” I think I’ve accomplished that--I'm happy to announce that River's Bend is now for sale at the Kindle Store.

Using the Creator to produce the .prc book for upload to the DTP is a different matter and will be the subject of a later post. Thanks for reading.


No comments:

Post a Comment

I encourage you to leave comments. I'll reply to all questions within a week, and errors in the posts will be acknowledged in the comment area. Feel free to answer questions/clarify confusion I express in my posts. Disagree with my points if you believe there is need for disagreement, but keep in mind that all off-topic comments, disparaging comments, comments with more than one link, and comments that include profanity will be deleted.