- PR -

cocoon 2.0.1でPDF中の日本語が化けます

1
投稿者投稿内容
mikiok
会議室デビュー日: 2002/02/06
投稿数: 6
投稿日時: 2002-02-07 00:11
cocoon 2.0.1 + tomcat 4.0.1を日本語Windows 2000+SP2で使用しています。日本語Font関連の設定をしたにもかかわらずPDFの出力で日本語が化けてしまいます(#になる)。同じconfig.xmlとFOP 0.20.2を使うと正常なPDFが作成できます。どなたかcocoon 2.0.1で日本語PDFを出力できた方はいらっしゃいませんか?

sitemap.xmapの設定:
<map:serializer name="fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer" logger="sitemap.serializer.fo2pdf" mime-type="application/pdf">
<user-config src="/fop-fonts/config.xml"/>
</map:serializer>

config.xml(fontの設定ファイル)は次のコマンドで作成した:
java -cp fop.jar org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho" %windir%\\Fonts\\msmincho.ttc msmincho.xml
java -cp fop.jar org.apache.fop.fonts.apps.TTFReader -ttcname "MS Gothic" %windir%\\Fonts\\msgothic.ttc msgothic.xml
mikiok
会議室デビュー日: 2002/02/06
投稿数: 6
投稿日時: 2002-02-07 00:18
自己レスです。

config.xml作成方法が間違っていました。内容は
<configuration>

<fonts>
<font metrics-file="/fop-fonts/msmincho.xml" kerning="yes" embed-file="C:/WINNT/Fonts/msmincho.ttc">
<font-triplet name="MS-Mincho" style="normal" weight="normal"/>
<font-triplet name="MS-Mincho" style="normal" weight="bold"/>
<font-triplet name="MS-Mincho" style="italic" weight="normal"/>
<font-triplet name="MS-Mincho" style="italic" weight="bold"/>
<font-triplet name="MSMincho" style="normal" weight="normal"/>
<font-triplet name="MSMincho" style="normal" weight="bold"/>
<font-triplet name="MSMincho" style="italic" weight="normal"/>
<font-triplet name="MSMincho" style="italic" weight="bold"/>
</font>
<font metrics-file="/fop-fonts/msgothic.xml" kerning="yes" embed-file="C:/WINNT/Fonts/msgothic.ttc">
<font-triplet name="MS-Gothic" style="normal" weight="normal"/>
<font-triplet name="MS-Gothic" style="normal" weight="bold"/>
<font-triplet name="MS-Gothic" style="italic" weight="normal"/>
<font-triplet name="MS-Gothic" style="italic" weight="bold"/>
<font-triplet name="MSGothic" style="normal" weight="normal"/>
<font-triplet name="MSGothic" style="normal" weight="bold"/>
<font-triplet name="MSGothic" style="italic" weight="normal"/>
<font-triplet name="MSGothic" style="italic" weight="bold"/>
</font>
</fonts>
</configuration>
です。

mikiok
会議室デビュー日: 2002/02/06
投稿数: 6
投稿日時: 2002-06-01 17:06
自己レスです。

cocoonに含まれるfopを展開してfop-0.20.3rc.jarのconfig.xmlにfontsの設定を追加して.jarファイルに固めなおして元に戻します。

環境:
Tomcat 4.0.4b3(jakarta-tomcat-4.0.4-b3-LE-jdk14.exe) + 2.0.2 + Java2 SDK 1.4.0

インストール方法:
1. cocoon(cocoon-2.0-bin.zip)を適当なフォルダで解凍します。
2. WEB-INF\lib\fop-0.20.3rc.jarを解凍する。
3. config.xmlにfontsの設定を追加する。
4. fop-0.20.3rc.jarに固めなおす。
5. WEB-INF\libに戻す。
ishida
会議室デビュー日: 2002/01/17
投稿数: 5
投稿日時: 2002-06-21 17:01
引用:

インストール方法:
1. cocoon(cocoon-2.0-bin.zip)を適当なフォルダで解凍します。
2. WEB-INFlibfop-0.20.3rc.jarを解凍する。
3. config.xmlにfontsの設定を追加する。
4. fop-0.20.3rc.jarに固めなおす。
5. WEB-INFlibに戻す。



はじめまして、ishidaと申します。
現在、私も以下のような状況でPDF変換処理の実験中です。
・jakarta-tomcat-4.0.4-LE-jdk14
・cocoon-2.0.1
・jdk1.4.0.01

色々なサイトを参考にさせてもらいましたが、なかなかうまくいきません。
「config.xmlへのfontsの設定」は貴重な情報に感謝しています。
あまりよく理解していないのかも知れませんが・・・ご質問させてください。

一番初めの書き込みの「map:serializer」は「map:components」の中に入るものなのでしょうか?見当違いならすみません。

宜しくお願い致します。
mikiok
会議室デビュー日: 2002/02/06
投稿数: 6
投稿日時: 2002-06-21 23:19
こんにちは。

map:serializerはsitemap.xmapの185行目あたりのmap:serializersの中にあります。

ちなみにcocoon.warを展開してFOPのconfig.xmlを編集するやり方の場合はsitemap.xmapの編集は必要ありません。

このあたりの情報はあまりないので、皆さんと情報が共有できたらこちらも助かるのですが... こちらでわかったことは、どんどんここで情報を発信したいと思います。
こちらこそよろしくお願いします。
mikiok
mikiok
会議室デビュー日: 2002/02/06
投稿数: 6
投稿日時: 2002-06-22 00:33
またまた自己レスです。

Windows 2000(SP2) + JDK 1.4.0_01 + Tomcat 4.0.4(jakarta-tomcat-4.0.4.exe:LEではないバージョンで最近releaseされてました) + cocoon 2.0.2で日本語が表示できました。ただし少しファイルを変更する必要があります。

1. cocoon.warを展開してfop-0.20.3rc.jarを取り出す
2. fop-0.20.3rc.jarを展開してconf/config.xmlを取り出す
3.fontの設定ファイルを作成しておく
4. conf/config.xmlの<configuration>に以下を追加してfop-0.20.3rc.jarを再度作成する。
ここで注意!! metrics-file="msmincho.ttf.xml"のmetrics-fileの指定にパスを入れないことが重要です。

<fonts>
<font metrics-file="msmincho.ttf.xml" kerning="yes" embed-file="C:/WINNT/Fonts/msmincho.ttc">
<font-triplet name="MS-Mincho" style="normal" weight="normal"/>
<font-triplet name="MS-Mincho" style="normal" weight="bold"/>
<font-triplet name="MS-Mincho" style="italic" weight="normal"/>
<font-triplet name="MS-Mincho" style="italic" weight="bold"/>
<font-triplet name="MSMincho" style="normal" weight="normal"/>
<font-triplet name="MSMincho" style="normal" weight="bold"/>
<font-triplet name="MSMincho" style="italic" weight="normal"/>
<font-triplet name="MSMincho" style="italic" weight="bold"/>
</font>
<font metrics-file="msgothic.ttf.xml" kerning="yes" embed-file="C:/WINNT/Fonts/msgothic.ttc">
<font-triplet name="MS-Gothic" style="normal" weight="normal"/>
<font-triplet name="MS-Gothic" style="normal" weight="bold"/>
<font-triplet name="MS-Gothic" style="italic" weight="normal"/>
<font-triplet name="MS-Gothic" style="italic" weight="bold"/>
<font-triplet name="MSGothic" style="normal" weight="normal"/>
<font-triplet name="MSGothic" style="normal" weight="bold"/>
<font-triplet name="MSGothic" style="italic" weight="normal"/>
<font-triplet name="MSGothic" style="italic" weight="bold"/>
</font>
</fonts>

5. fontの設定ファイル(msmincho.ttf.xml、msgothic.ttf.xml)をtomcatをインストールしたディレクトリ(%TOMCAT_HOME%または%CATALINA_HOME%)にコピーする。例えばd:\tomcat4.0.4。ファイルの指定にパスをいれるとうまくいかないのでFOPのバグのような気がします。パスがない場合はtomcatのrootを見に行くようです。
6. hello.pdf用のサンプルコードを編集する
d:\tomcat4.0.4\webapps\cocoon\docs\samples\hello-page.xmlの内容
<?xml version="1.0" encoding="SHIFT_JIS"?>

<!-- CVS: $Id: hello-page.xml,v 1.2 2002/02/09 06:21:57 vgritsenko Exp $ -->

<!DOCTYPE page [
<!ELEMENT page (title?, content)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT content (para+)>
<!ELEMENT para (#PCDATA)>
]>

<page>
<title>こんにちは</title>
<content>
<para>最初のページです。</para>
</content>
</page>

7.d:\tomcat4.0.4\webapps\cocoon\stylesheets\page\simple-page2fo.xslを編集する
(最後の部分)

<xsl:template match="title">
<fo:block font-size="36pt" font-family="MSGothic" space-before.optimum="24pt" text-align="center"><xsl:apply-templates/></fo:block>
</xsl:template>

<xsl:template match="para">
<fo:block font-size="12pt" font-family="MSGothic" space-before.optimum="12pt" text-align="center"><xsl:apply-templates/></fo:block>
</xsl:template>

これで日本語が表示できました!!!
ishida
会議室デビュー日: 2002/01/17
投稿数: 5
投稿日時: 2002-06-25 10:28
mikiokさん こんにちわ

有益な情報をありがとうございます。

その情報を元に試行錯誤中ですが、なかなかうまくいかずです。
(違うのは cocoon のバージョンだけなのに・・・2.0.1)

多少PDFレイアウト系に興味が移りつつありますが・・・
これからも何かわかりましたら宜しくお願いします。

勉強不足な私もいつか力になれればと思います。
mikiok
会議室デビュー日: 2002/02/06
投稿数: 6
投稿日時: 2002-07-15 23:10
こんにちは。

http://xml.apache.org/cocoon/をのぞいたらv2.0.3がリリースされていたので早速試してみました。以下の環境でsitemap.xmapを変更するだけで日本語PDFが表示できました。

OS: Windows 2K +SP2 Pro 日本語版
J2SDK: 1.4.0_01
Tomcat: 4.0.4(jakarta-tomcat-4.0.4.exe)
cocoon: 2.0.3(cocoon-2.0.3-vm14-bin.zip)

インストール方法:
1. %TOMCAT_HOME%\webappsにcocoon.warをコピーする
2. tomcatを起動する
3. %TOMCAT_HOME%\webapps\cocoon\sitemap.xmapの182行目あたりを次のように変更する
変更前:
<map:serializer mime-type="application/pdf" name="fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer"/>

変更後:
<map:serializer name="fo2pdf"
src="org.apache.cocoon.serialization.FOPSerializer"
mime-type="application/pdf">
<user-config src="D:/fop-fonts/config.xml"/>
</map:serializer>

d:/fop-fonts/config.xmlの内容(d:/fop-fontsにはmsmincho.ttf.xml、msgothic.ttf.xmlファイルを用意しておく):
<configuration>

<fonts>
<font metrics-file="d:/fop-fonts/msmincho.ttf.xml" kerning="yes" embed-file="C:/WINNT/Fonts/msmincho.ttc">
<font-triplet name="MS-Mincho" style="normal" weight="normal"/>
<font-triplet name="MS-Mincho" style="normal" weight="bold"/>
<font-triplet name="MS-Mincho" style="italic" weight="normal"/>
<font-triplet name="MS-Mincho" style="italic" weight="bold"/>
<font-triplet name="MSMincho" style="normal" weight="normal"/>
<font-triplet name="MSMincho" style="normal" weight="bold"/>
<font-triplet name="MSMincho" style="italic" weight="normal"/>
<font-triplet name="MSMincho" style="italic" weight="bold"/>
</font>
<font metrics-file="d:/fop-fonts/msgothic.ttf.xml" kerning="yes" embed-file="C:/WINNT/Fonts/msgothic.ttc">
<font-triplet name="MS-Gothic" style="normal" weight="normal"/>
<font-triplet name="MS-Gothic" style="normal" weight="bold"/>
<font-triplet name="MS-Gothic" style="italic" weight="normal"/>
<font-triplet name="MS-Gothic" style="italic" weight="bold"/>
<font-triplet name="MSGothic" style="normal" weight="normal"/>
<font-triplet name="MSGothic" style="normal" weight="bold"/>
<font-triplet name="MSGothic" style="italic" weight="normal"/>
<font-triplet name="MSGothic" style="italic" weight="bold"/>
</font>
</fonts>
</configuration>
1

スキルアップ/キャリアアップ(JOB@IT)