<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<article>
<sect1>
<title>Hello World</title>
<para>Hello World</para>
</sect1>
<sect1>
<title>日本語テスト</title>
<para>日本語が正しく表示されますか?</para>
</sect1>
<sect1>
<title>hoge</title>
<para>hello</para>
<sect2>
<title>hoge2</title>
<para>hogehoge</para>
</sect2>
</sect1>
</article>
標準
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> <xsl:import href="../docbook-xsl-1.75.0/fo/docbook.xsl"/> <xsl:output method="fo" encoding="UTF-8" indent="yes"/> <xsl:param name="section.autolabel" select="1"/> <xsl:param name="default.encoding" select="'UTF-8'"/> <xsl:param name="paper.type" select="'A4'"/> <xsl:param name="title.font.family" select="'Meiryo'"/> <xsl:param name="body.font.family" select="'Meiryo'"/> <xsl:param name="sans.font.family" select="'Meiryo'"/> <xsl:param name="monospace.font.family" select="'Meiryo'"/> </xsl:stylesheet>
文章全体の上下 margin を調整
次の指定を xsl に追加
<xsl:param name="page.margin.top">10mm</xsl:param> <xsl:param name="page.margin.bottom">10mm</xsl:param>
本文上下の margin を調整
次の指定を xsl に追加
<xsl:param name="body.margin.top">0mm</xsl:param> <xsl:param name="body.margin.bottom">0mm</xsl:param>
本文左右の margin を調整
次の指定を xsl に追加
<xsl:param name="page.margin.inner">0mm</xsl:param> <xsl:param name="page.margin.outer">0mm</xsl:param>
段落の開始位置 左 margin を調整
次の指定を xsl に追加
<xsl:param name="body.start.indent">0pt</xsl:param>
Table of Contents, List of Figures なし
次の指定を xsl に追加
<xsl:param name="generate.toc"> article nop </xsl:param>
Header に draft を入れる, Background に draft 画像を貼る
次の指定を xsl に追加
<xsl:param name="draft.mode">yes</xsl:param> <xsl:param name="draft.watermark.image">file:///c:\usr\share\sgml\docbook-xsl-1.75.0\images\draft.png</xsl:param>draft.watermark.image を指定しないと HTTP 通信をして draft.png ファイルを取得しようとするので, ネットワークがつながっていない・Proxy が設定されていない等でエラーとなった場合に下記の表示が出る
[fop] 致命的: Error with opening URL 'http://docbook.sourceforge.net/release/images/draft.png': Connection timed out: connect
Header, Footer に罫線なし
次の指定を xsl に追加
<xsl:param name="header.rule" select="0"></xsl:param> <xsl:param name="footer.rule" select="0"></xsl:param>
ページ定義
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple"
page-height="297mm"
page-width="210mm"
margin-top="10mm"
margin-bottom="20mm"
margin-left="25mm"
margin-right="25mm">
<fo:region-body margin-top="30mm"/>
<fo:region-before extent="30mm"/>
<fo:region-after extent="15mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simple">
<fo:flow flow-name="xsl-region-body">
<fo:block font-size="18pt" padding-top="3pt" padding-bottom="10pt">
TITLE
</fo:block>
<fo:block font-size="12pt" font-family="sans-serif">
hogehoge
</fo:block>
<fo:block font-size="14pt" font-family="IPA Mincho">
ほげほげ
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
- ページの定義は以下の部分
page-height="297mm" page-width="210mm" margin-top="10mm" margin-bottom="20mm" margin-left="25mm" margin-right="25mm"
長さ 297mm x 幅 210mm は A4 サイズの用紙 - 文章本体は以下の部分で定義
<fo:region-body margin-top="30mm"/>
- ヘッダ部分
<fo:region-before extent="30mm"/>
- フッター部分
<fo:region-after extent="15mm"/>
- 以下の箇所が文章本体。master-reference では先に定義していたページ情報を指定する。
<fo:page-sequence master-reference="simple"> : </fo:page-sequence> - 以下の箇所でbody 部分に記載する内容を定義する。body 部分であることは xsl-region-body で指定している。
<fo:flow flow-name="xsl-region-body"> : </fo:flow>
region
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xml:lang="ja">
<fo:layout-master-set>
<fo:simple-page-master page-height="148mm"
page-width="105mm"
margin-top="10mm"
margin-left="20mm"
margin-right="20mm"
margin-bottom="10mm"
master-name="PageMaster">
<fo:region-body background-color="#cccccc"
margin-top="20mm"
margin-left="20mm"
margin-right="20mm"
margin-bottom="20mm"/>
<fo:region-before background-color="#00ffff" extent="15mm"/>
<fo:region-after background-color="#00ffff" extent="15mm"/>
<fo:region-start background-color="#ffffcc" extent="15mm"/>
<fo:region-end background-color="#ffffcc" extent="15mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence initial-page-number="1" master-reference="PageMaster">
<fo:static-content flow-name="xsl-region-start">
<fo:block>region-start</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-end">
<fo:block>region-end</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-before">
<fo:block>region-before</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block>region-after</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>region-body</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
文章位置調整のパラメータは下表・下図のようになっている
Table: region
| simple-page-master | margin-top | (1) |
| margin-left | (2) | |
| margin-right | (3) | |
| margin-bottom | (4) | |
| region-body | margin-top | (5) |
| margin-left | (6) | |
| margin-right | (7) | |
| margin-bottom | (8) | |
| region-before | extent | (9) |
| region-start | extent | (10) |
| region-end | extent | (11) |
| region-after | extent | (12) |






































