ほんじゃらねっと

ダイエット中プログラマのブログ

CentOS環境でrst2pdfを使って日本語PDFを出力する

riv.vimのpdf出力機能がどうしてもうまく動かせないので、
pythonのrst2pdfで直接出力することにした。

easy_installでrst2pdfをインストールし、以下の設定ファイルで日本語に対応する。
ほぼ参考サイトのまま。

~/rst2pdf/config

[general]
# カンマ区切りのカスタムスタイルシートのリスト。
stylesheets="~/.rst2pdf/ja.json"
# 圧縮されたPDFを生成
# 使用する true/false (全て小文字) もしくは 1/0
compressed=false
# コロン区切りのフォントサーチパスのリスト
font_path="/usr/share/fonts"
# 言語のハイフネーションサポート
language="ja_JP"
# デフォルトのページヘッダとページフッタ
header=""
footer=""
# リテラルブロックが大きすぎる場合の処理
# shrink/truncate/overflow
fit_mode="shrink"
# 改ページ処理のヘッディング最大レベルを指定します。
# 0は改ページ処理のレベルを設定しないことを意味します。
break_level=0


~/rst2pdf/ja.json

{
"embeddedFonts" :
[["vlgothic/VL-Gothic-Regular.ttf","vlgothic/VL-PGothic-Regular.ttf","ipa-mincho/ipam.ttf","vlgothic/VL-Gothic-Regular.ttf"]],
"fontsAlias" : {
"stdFont": "VL-PGothic-Regular",
"stdBold": "VL-PGothic-Regular",
"stdItalic": "VL-PGothic-Regular",
"stdMono": "VL-Gothic-Regular"
},
"styles" : [
["base" , {
"wordWrap": "CJK"
}],
["literal" , {
"wordWrap": "None"
}]
]
}
参考サイト

rst2pdf拡張を使ったPDFファイル作成
http://sphinx-users.jp/cookbook/pdf/rst2pdf.html

rst2pdfの日本語周り設定
http://d.hatena.ne.jp/aroma_black/20100630/1277867889

rst2pdfをWindowsで使ってみた
http://d.hatena.ne.jp/nullpobug/20090424/1240510391

rst2pdf で reStructuredText から PDF を生成する
http://sakito.jp/python/rst2pdf.html