日本語例
JRServletにも例がありますがここで説明します。
固定文字
【サンプル】
<staticText>
<reportElement
mode="Opaque"
x="0"
y="127"
width="163"
height="40"
forecolor="#000000"
backcolor="#FFFFFF"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">
<font fontName="sansserif" pdfFontName="HeiseiKakuGo-W5" size="12" isBold="false" isItalic="false"
isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="UniJIS-UCS2-HW-H" isStrikeThrough="false" />
</textElement>
<text><![CDATA[日本語サンプル3ゴシック]]></text>
</staticText>
【解説】
- 固定文字なので<staticText>タグを使用します。
- <textElement>タグで書式を指定します。
ここで重要となる<font />タグで
pdfFontName="HeiseiKakuGo-W5"
pdfEncoding ="UniJIS-UCS2-HW-H"
で指定します。- <text>タグで日本語を表示します。
可変文字
【サンプル】
<textField isStretchWithOverflow="true" pattern="" isBlankWhenNull="true" evaluationTime="Now"
hyperlinkType="None" > <reportElement
mode="Opaque"
x="356"
y="0"
width="178"
height="15"
forecolor="#000000"
backcolor="#FFFFFF"
positionType="FixRelativeToTop"
isPrintRepeatedValues="true"
isRemoveLineWhenBlank="false"
isPrintInFirstWholeBand="false"
isPrintWhenDetailOverflows="false"/>
<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">
<font fontName="sansserif" pdfFontName="HeiseiKakuGo-W5" size="12" isBold="false" isItalic="false"
isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="UniJIS-UCS2-H" isStrikeThrough="false" />
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{ETC}]]></textFieldExpression>
</textField>
【解説】
- 可変文字なので<textField>タグを使用します。
- <textElement>タグで書式を指定します。
ここで重要となる<font />タグで
pdfFontName="HeiseiKakuGo-W5"
pdfEncoding ="UniJIS-UCS2-H"
で指定します。- <textFieldExpression>タグで日本語の可変部を表示します。