More Links

Main Site and Blog:
    Spontaneous Derivation

Email:
    arachne.jericho@gmail.com

Target: Mobipocket

Notes

Mobipocket files come in two flavors: PRC and MOBI. PRC is closer to a basic Palm document, while a MOBI file wraps the original PRC in another layer. However, both formats have the same capabilities with respect to meta-data, image support, CSS support, and multiple HTML files; and many readers (including the Kindle) that can read one can also read the other.

However, PRC is more inclusive, since PRC documents are not the single realm of just Mobipocket (unlike the MOBI format).

In either case, what I usually do is first create the Epub and add Mobipocket compatability; then the creation of either a PRC file (easy) or a MOBI file (easy if you have command line fu) naturally follows.

Adding Mobipocket Compatibility to Epub

In the Epub’s project directory:

  1. Add an HTML table of contents file explicitly for Mobipocket; I usually call it toc.html and put it in the content directory.
  2. Then add the ToC file to the manifest and spine sections of the metadata.opf file.
  3. Add a reference to your table of contents HTML in the guide section of the metadata.opf file. The end result looks something like this:
      <guide>
    <reference type="toc" title="Table of Contents"
    href="content/toc.html"/>

    </guide>

RubyEpub Tools

If you’re using RubyEpub tools, here are the commands I use after creating toc.html:

tufor% epub add-to-opf . content/toc.html
tufor% [edit metadata.opf to reorder the spine]
tufor% epub compile .

Generating PRC with Mobipocket Creator

  1. Open Mobipocket Creator.
  2. Tell it to open an existing project, and navigate to the metadata.opf file in your Epub directory.
  3. Build the project as usual. You’ll get a PRC named metadata.prc, which you’ll need to rename.

Generating MOBI with Mobigen

You definitely need CrossOver for this.

To install mobigen.exe, download it from the Mobipocket development center (right side). Once you unzip the file, there will be a mess there. Find the mobigen.exe file, which may have some junk plus , and rename it to mobigen.exe:

tufor% mv [junk with ]mobigen.exe mobigen.exe

You likely can’t do this from Finder, because it’s the bad translation of a DOS file system (hence the backslashes) to a Unix file system (which uses forward slashes).

Then place the following in a script file somewhere:

#!/bin/sh
MOBIGEN="$HOME/Software/mobigen/mobigen.exe"
export 'FONT_ENCODINGS_DIRECTORY'='/Applications/CrossOver.app/Contents/SharedSupport/X11/lib/X11/fonts/encodings/encodings.dir'
export 'CX_BOTTLE_PATH'='/Users/ajar/Library/Application Support/CrossOver/Bottles'
export 'Apple_PubSub_Socket_Render'='/tmp/launch-HtqXLr/Render'
export 'FONTCONFIG_ROOT'='/Applications/CrossOver.app/Contents/SharedSupport/X11'
export 'CX_ROOT'='/Applications/CrossOver.app/Contents/SharedSupport/CrossOver'
export 'SSH_AUTH_SOCK'='/tmp/launch-JHS5Yh/Listeners'
export 'COMMAND_MODE'='legacy'
export 'TMPDIR'='/var/folders/Uq/UqsgL-Ju2RWNH++8ZP3Nj++++TI/-Tmp-/'
export 'FONTCONFIG_PATH'='/Applications/CrossOver.app/Contents/SharedSupport/X11/etc/fonts'
export 'DISPLAY'=':2'
export 'DYLD_FALLBACK_LIBRARY_PATH'='/Applications/CrossOver.app/Contents/SharedSup
port/X11/lib:/Users/ajar/lib:/usr/local/lib:/lib:/usr/lib'
export CX_BOTTLE='win2k'
export PATH="$PATH:"'/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin'
wine $MOBIGEN "$@"

Place this script in a directory that’s on your PATH.

Once all that is over, you can simply do this in the future:

  1. tufor% mobigen -s0 -c1 EPUB-FILE

This generates a MOBI file with a similar name in the current directory.