FO Plug-inでFormatterを使う

山ほどFO Plug-inの悪口を書いてしまいました.それでも、それでも、それでも、それでも、それでも、FO Plug-inを使いたい方はいらっしゃるようです.一所懸命トライしているのだがFomratterでうまく動かないという問い合わせをいただきました.確かにWEBを見るといろいろ情報があるのですが、少し内容が古く今のDITA-OTにあっていない記述もあるようです.せっかくなのでAntenna House Formatter(またはXSL Formatter)を、FO Plug-inで動かす方法を紹介しておきます.
 
■ DITA-OT
最新のものを選ぶのが良い選択です.古い枯れたバージョンの方が良くないか?とおっしゃる方もいますが、正直バグの山です.DITA-OT 1.5.1もテーブル処理に致命的なバグがあります.現在だったらステーブルな1.5.2でしょう.落とすのだったら、http://sourceforge.net/projects/dita-ot/files/ で、DITA-OT1.5.2_full_easy_install_bin.zip (27.4 MB)を選択するのが良いと思います.
 
■ フォントマッピングの変更
インストールしたら、フォントマッピングを標準的なWindowsのものに書き換えます.[DITA-OT]\demo\fo\cfg\fo\font-mappings.xmlのバックアップを取り、内容を次のように修正します.(もちろん好みのフォントを選ばれてもかまいません)
<?xml version="1.0"?>
<font-mappings>
    <font-table>
        <aliases>
            <alias name="Arial">Normal</alias>
        </aliases>
        <aliases>
            <alias name="Courier New">Monospaced</alias>
        </aliases>
        <logical-font name="Sans">
            <physical-font char-set="default">
                <font-face>Arial</font-face>
            </physical-font>
            <physical-font char-set="Simplified Chinese">
                <font-face>SimHei</font-face>
            </physical-font>
            <physical-font char-set="Japanese">
                <font-face>MS-Gothic</font-face>
            </physical-font>
            <physical-font char-set="Korean">
                <font-face>Gulim</font-face>
            </physical-font>
            <physical-font char-set="Symbols">
                <font-face>ZapfDingbats</font-face>
            </physical-font>
            <physical-font char-set="SubmenuSymbol">
                <font-face>ZapfDingbats</font-face>
            </physical-font>
            <physical-font char-set="SymbolsSuperscript">
                <font-face>Arial</font-face>
                <baseline-shift>20%</baseline-shift>
                <override-size>smaller</override-size>
            </physical-font>
        </logical-font>
        <logical-font name="Serif">
            <physical-font char-set="default">
                <font-face>Times New Roman</font-face>
            </physical-font>
            <physical-font char-set="Simplified Chinese">
                <font-face>SimSun</font-face>
            </physical-font>
            <physical-font char-set="Japanese">
                <font-face>MS-Mincho</font-face>
            </physical-font>
            <physical-font char-set="Korean">
                <font-face>Batang</font-face>
            </physical-font>
            <physical-font char-set="Symbols">
                <font-face>ZapfDingbats</font-face>
            </physical-font>
            <physical-font char-set="SubmenuSymbol">
                <font-face>ZapfDingbats</font-face>
            </physical-font>
            <physical-font char-set="SymbolsSuperscript">
                <font-face>Times New Roman</font-face>
                <baseline-shift>20%</baseline-shift>
                <override-size>smaller</override-size>
            </physical-font>
        </logical-font>
        <logical-font name="Monospaced">
            <physical-font char-set="default">
                <font-face>Courier New</font-face>
            </physical-font>
            <physical-font char-set="Simplified Chinese">
                <font-face>SimHei</font-face>
            </physical-font>
            <physical-font char-set="Japanese">
                <font-face>MS-Gothic</font-face>
            </physical-font>
            <physical-font char-set="Korean">
                <font-face>GulimChe</font-face>
            </physical-font>
            <physical-font char-set="Symbols">
                <font-face>ZapfDingbats</font-face>
            </physical-font>
            <physical-font char-set="SymbolsSuperscript">
                <font-face>Courier New</font-face>
                <baseline-shift>20%</baseline-shift>
                <override-size>smaller</override-size>
            </physical-font>
        </logical-font>
    </font-table>
</font-mappings>
 
コマンドライン
[DITA-OT]\startcmd.batをエクスプローラでクリックし、コマンドウィンドウを開きます.ここで、次のコマンドラインを入力すれば良いです.
ant -l [ログファイルのパス] -Dargs.input=[ditamapのパス] -Dpdf.formatter=ah -Dtranstype=pdf
 
■ ご注意
(1) Formatterのインストールフォルダ
FO Plug-inのビルドファイル([DITA-OT]\demo\fo\build.xml)は、自動的にAntenna House Formatter (XSL Formatter)のインストールディレクトリをサーチしてくれます.これはFormatterが標準的なインストールフォルダにインストールされているが前提です.標準的なフォルダとは次のようなものです.
C:\Program Files\AntennaHouse\AHFormatterV53
C:\Program Files\AntennaHouse\AHFormatterV52
C:\Program Files\AntennaHouse\AHFormatterV51
C:\Program Files\AntennaHouse\AHFormatterV5
C:\Program Files\Antenna\XSLFormatterV43
C:\Program Files\Antenna\XSLFormatterV42
もしこれ以外のフォルダにインストールした場合、自分でビルドファイルを修正するのがイヤだったら、環境変数"AXF_DIR"にフォルダのパスを設定しておけば動くはずです.また複数のバージョンをインストールしてあって、起動するバージョンを指定する場合もこの方法が有効です.
例)AXF_DIR=C:\Program Files\AntennaHouse\Formatter\AHFormatterV53
環境変数の設定は、Windows7だったら、コントロールパネル-システム-システムの詳細設定-環境変数から行えます.
あとFO Plug-inのビルドファイルでは、"-peb 1" のコマンドラインスイッチをつけて、フォント埋め込みをするようにしています.V4.0などあまり古いFormatterだとこのスイッチが認識されずエラーとなります.