【改訂前】DITA-OT1.4.3のPDF出力を日本語化する(RenderX XEP編)
【重要】
以下では、DITA-OT1.4.2.1の%DITA-OT%demo\fo\lib\fo.jarを流用してFO plug-inをセットアップする手順を紹介していますが、このセットアップ手順はお薦めできません。より適切なセットアップ手順をアップしましたので、こちらを見てください。
【改訂後】DITA-OT1.4.3のPDF出力を日本語化する(RenderX XEP編)
DITA-OT1.4.2.1までは、PDF2出力を使うためにFO plug-inをインストールする必要があった。
DITA-OT1.4.3からは、FO plug-inが最初からDITA-OTに組み込まれている。
出力タイプにPDFまたはPDF2を指定すると、従来のFO plug-inのコードが実行される。
しかし、残念ながらRenderX XEPを使うために必要ないくつかのjarファイルがDITA-OT1.4.3には含まれていない。
ソースコードからビルドするか、DITA-OT1.4.2.1の中にあるjarファイルをコピーしなければならない。
以下の説明では、DITA-OT1.4.3で不足しているjarファイルを、DITA-OT1.4.2.1からコピーする方法を示している。
ちなみに、1.4.2.1以前のPDF出力を使うには、出力タイプにlegacypdfを指定する。
RenderX XEPのインストール
- 以下のURLから、RenderX personal edition(無料)を入手する。
- 上記ページの"Personal License Download"の、Name, Organization, Emailの各テキスト・ボックスに必要事項を入力し、[Submit]ボタンをクリックする。
- "Download instructions: RenderX XEP v4 Trial Software"というタイトルのメールが送られてくる。このメールには、"license.xml"というファイルが添付されている。
- "license.xml"を、%DITA-OT%demo\fo\lib\xep フォルダの下に保存する。
- メール本文に書かれているURLにアクセスし、"Select your license key"のテキスト・ボックスの右横にある[参照...]ボタンをクリックし、4)で保存したlicense.xmlファイルを選択する。
- [Update]ボタンをクリックすると、Webブラウザの別ウィンドウにインストール・ファイル(xep-4.14-20081212-personal.zip)のリンクが表示されるので、そのリンクをクリックしてzipファイルをダウンロードする。
- ダウンロードしたzipファイルを解凍すると、以下のファイルができる。
- LICENSE-PERSONAL.TXT
- readme.txt
- xep-4.14-20081212-personal.zip
- readme.txt に書かれているインストール手順に従って、コマンド・プロンプトから以下のコマンドを実行する。
java -jar setup-4.14-20081212-personal.jar
- RenderX license agreementのダイアログ・ボックスが表示されたら、ライセンス条項を読み[Yes, I accept]ボタンをクリックする。
- RenderX XEP setupのダイアログ・ボックスが表示されたら、2つのテキスト・ボックスにそれぞれ以下のパスを入力し、[Install]ボタンをクリックする。
- Install XEP to the directory: %DITA-OT%demo\fo\lib\xep
- License file: %DITA-OT%demo\fo\lib\xep\license.xml
- "Installation successful"のメッセージが表示されたら、[Finish]ボタンをクリックする。
Saxon Version 6.5.5のインストールと設定
DITA-OT1.4.3にはSaxon 9Bが含まれているが、Saxon 9BではRenderX XEPを使ったPDF出力を実行するとエラーになる。
- 以下のURLから、Saxon Version 6.5.5 のインストール・ファイル(saxon6-5-5.zip)をダウンロードする。
- ダウンロードしたzipファイルを解凍し、できたフォルダを適当な場所(例えば、C:\tools\saxon6-5-5)に移動する。
- 上記フォルダの中の saxon.jar を、%DITA-OT%demo\fo\lib\xep\lib にコピー(既存のsaxon.jarを上書きする)する。
- %DITA-OT%demo\fo\build.xml の以下の箇所を変更し、PDF出力時のXSLTエンジンとしてSaxon Version 6.5.5が使われるようにする。
一箇所目
<path id="project.class.path"> <!-- <pathelement path="${java.class.path}"/> <fileset dir="${lib.dir}/saxon"> <include name="**/*.jar"/> </fileset> --> <pathelement location="${fo.lib.dir}/xep/lib/saxon.jar"/> <pathelement location="${lib.dir}/xml-apis.jar"/> <pathelement location="${lib.dir}/xercesImpl.jar"/> <pathelement location="${lib.dir}/resolver.jar"/> <pathelement location="${lib.dir}/icu4j.jar"/> <pathelement location="${fo.lib.dir}/fo.jar"/> </path>
二箇所目
<!--Decide which version of saxon to use.--> <!--<available classname="net.sf.saxon.Transform" property="fo.saxon.classname" value="net.sf.saxon.Transform" classpathref="project.class.path"/>--> <property name="fo.saxon.classname" value="com.icl.saxon.StyleSheet"/>
FO FormatterをApache FOPからRenderX XEPに変更する
DITA-OT1.4.3からは、Apache FOPがデフォルトのFO Formatterになっている。
FO FormatterとしてRenderX XEPを使うようにする手順は以下のとおり。
- %DITA-OT%demo\fo\build.xml の中で、pdf.formatter というプロパティに fop が指定されているので、この値を xep に変更する。
※おまけ
build.xmlのデフォルトの設定では、DITA-OT実行後にXSL-FOのファイルが削除される。
デバッグのためにXSL-FOを残しておきたい場合は、build.xml の中の、transform.topic2pdfターゲットの定義の中の、deleteの部分をコメント・アウトする。
<!--<delete>--> <!--Deleting the stage files isn't necessary, since it will be cleaned by clean-temp, and is useful for debugging.--> <!--<fileset dir="${buildDir}" includes="stage?.*"/>--> <!--<fileset dir="${dita.map.output.dir}" includes="topic.fo"/>--> <!--</delete>-->
- DITA-OT1.4.3の %DITA-OT%demo\fo\lib\fo.jar の中にRenderX XEPを起動するためのクラスが含まれていないので、DITA-OT1.4.2.1の %DITA-OT%demo\fo\lib\fo.jar をコピーする(既存のfo.jarを上書きする)。
日本語対応のための設定
- %DITA-OT%demo\fo\build.xml の中で、document.locale というプロパティを設定しているので、この値を ja_JP に変える。このことについては、DITA Open Toolkit User Guideの"Localizing in PDF2 output target"に書いてある。このlocaleに指定により、自動生成文字や索引の出来方も日本語仕様になる。
- %DITA-OT%demo\fo\lib\xep\xep.xml の
定義の箇所の、TrueType fontsの定義のコメント・アウトを解除し、以下のように MSGothic と MSMincho の定義を追加する。
<!-- Sample configuration for Windows TrueType fonts. --> <font-group xml:base="file:/C:/Windows/Fonts/" label="Windows TrueType" embed="true" subset="true"> <font-family name="Arial"> <font><font-data ttf="arial.ttf"/></font> <font style="oblique"><font-data ttf="ariali.ttf"/></font> <font weight="bold"><font-data ttf="arialbd.ttf"/></font> <font weight="bold" style="oblique"><font-data ttf="arialbi.ttf"/></font> </font-family> <font-family name="Times New Roman" ligatures="fi fl"> <font><font-data ttf="times.ttf"/></font> <font style="italic"><font-data ttf="timesi.ttf"/></font> <font weight="bold"><font-data ttf="timesbd.ttf"/></font> <font weight="bold" style="italic"><font-data ttf="timesbi.ttf"/></font> </font-family> <font-family name="Courier New"> <font><font-data ttf="cour.ttf"/></font> <font style="oblique"><font-data ttf="couri.ttf"/></font> <font weight="bold"><font-data ttf="courbd.ttf"/></font> <font weight="bold" style="oblique"><font-data ttf="courbi.ttf"/></font> </font-family> <font-family name="Tahoma" embed="true"> <font><font-data ttf="tahoma.ttf"/></font> <font weight="bold"><font-data ttf="tahomabd.ttf"/></font> </font-family> <font-family name="Verdana" embed="true"> <font><font-data ttf="verdana.ttf"/></font> <font style="oblique"><font-data ttf="verdanai.ttf"/></font> <font weight="bold"><font-data ttf="verdanab.ttf"/></font> <font weight="bold" style="oblique"><font-data ttf="verdanaz.ttf"/></font> </font-family> <font-family name="Palatino" embed="true" ligatures="ff fi fl ffi ffl"> <font><font-data ttf="pala.ttf"/></font> <font style="italic"><font-data ttf="palai.ttf"/></font> <font weight="bold"><font-data ttf="palab.ttf"/></font> <font weight="bold" style="italic"><font-data ttf="palabi.ttf"/></font> </font-family> <!-- Begin Japanese --> <font-family name="MSGothic"> <font><font-data ttf="msgothic.ttc"/></font> <font style="oblique"><font-data ttf="msgothic.ttc"/></font> <font weight="bold"><font-data ttf="msgothic.ttc"/></font> <font weight="bold" style="oblique"><font-data ttf="msgothic.ttc"/></font> </font-family> <font-family name="MSMincho"> <font><font-data ttf="msmincho.ttc"/></font> <font style="oblique"><font-data ttf="msmincho.ttc"/></font> <font weight="bold"><font-data ttf="msmincho.ttc"/></font> <font weight="bold" style="oblique"><font-data ttf="msmincho.ttc"/></font> </font-family> <!-- End Japanese --> </font-group>
- フォント・マッピングをカスタマイズするために、%DITA-OT%demo\fo\cfg\fo\font-mappings.xml を %DITA-OT%demo\fo\Customization\fo の下にコピーする。
- %DITA-OT%\demo\fo\Customization\fo\font-mappings.xml を編集し、日本語フォントの指定箇所を以下のとおり変更する。
<font-mappings> <font-table> <aliases> <alias name="Helvetica">Normal</alias> </aliases> <aliases> <alias name="Courier">Monospaced</alias> </aliases> <logical-font name="Sans"> <physical-font char-set="default"> <font-face>Helvetica</font-face> </physical-font> <physical-font char-set="Simplified Chinese"> <font-face>AdobeSongStd-Light</font-face> </physical-font> <physical-font char-set="Japanese"> <!--font-face>KozMinProVI-Regular</font-face--> <font-face>MSGothic</font-face> </physical-font> <physical-font char-set="Korean"> <font-face>AdobeMyungjoStd-Medium</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>Helvetica</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</font-face> </physical-font> <physical-font char-set="Simplified Chinese"> <font-face>AdobeSongStd-Light</font-face> </physical-font> <physical-font char-set="Japanese"> <!--font-face>KozMinProVI-Regular</font-face--> <font-face>MSMincho</font-face> </physical-font> <physical-font char-set="Korean"> <font-face>AdobeMyungjoStd-Medium</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</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</font-face> </physical-font> <physical-font char-set="Simplified Chinese"> <font-face>AdobeSongStd-Light</font-face> </physical-font> <physical-font char-set="Japanese"> <!--font-face>KozMinProVI-Regular</font-face--> <font-face>MSGothic</font-face> </physical-font> <physical-font char-set="Korean"> <font-face>AdobeMyungjoStd-Medium</font-face> </physical-font> <physical-font char-set="Symbols"> <font-face>ZapfDingbats</font-face> </physical-font> <physical-font char-set="SymbolsSuperscript"> <font-face>Courier</font-face> <baseline-shift>20%</baseline-shift> <override-size>smaller</override-size> </physical-font> </logical-font> </font-table> </font-mappings>
- font-mappings.xml のカスタマイズを有効にするために、%DITA-OT%demo\fo\Customization\catalog.xml を修正する。catalog.xml.orig をコピーして catalog.xml を作り、FontMapperのコメントを解除する。
<!-- FontMapper configuration override entry.--> <uri name="cfg:fo/font-mappings.xml" uri="fo/font-mappings.xml"/>