当方の環境はMacOSX 10.7になっております。
Windows/Linuxの方はコマンドやディレクトリなどを
ご自身の環境に置き換えて作成下さい。
また以下のものがインストールされている前提となっています。
rst2pdfのインストール
Windows/Linuxの方はコマンドやディレクトリなどを
ご自身の環境に置き換えて作成下さい。
また以下のものがインストールされている前提となっています。
- Python
- pip
コマンドラインから
日本語フォントのインストール
日本語出力のためのスタイル設定
$ pip install rst2pdf
これより下のファイルはプロジェクトディレクトリ内に作成します。
フォントの埋め込み
% vi ja.styleja.styleに以下のように記述します。
{
"fontsAlias" : {
"stdFont": "VL-PGothic-Regular",
"stdBold": "VL-PGothic-Regular",
"stdItalic": "VL-PGothic-Regular",
"stdBoldItalic": "VL-PGothic-Regular",
"stdMono": "VL-Gothic-Regular",
"stdMonoBold": "VL-Gothic-Regular",
"stdMonoItalic": "VL-Gothic-Regular",
"stdMonoBoldItalic": "VL-Gothic-Regular",
"stdSans": "VL-Gothic-Regular",
"stdSansBold": "VL-Gothic-Regular",
"stdSansItalic": "VL-Gothic-Regular",
"stdSansBoldItalic": "VL-Gothic-Regular"
},
"styles" : [
["base" , {
"wordWrap": "CJK"
}],
["literal" , {
"wordWrap": "None"
}]
]
}
% vi ja.jsonja.jsonに以下のように記述します。
{
"embeddedFonts" :
[[
"VL-Gothic-Regular.ttf",
"VL-PGothic-Regular.ttf",
"ipam.ttf",
"ipag.ttf",
"ipagp.ttf",
"ipamp.ttf"
]],
"fontsAlias" : {
"stdFont": "VL-PGothic-Regular",
"stdBold": "VL-PGothic-Regular",
"stdItalic": "VL-PGothic-Regular",
"stdBoldItalic": "VL-PGothic-Regular",
"stdMono": "VL-Gothic-Regular",
"stdMonoBold": "VL-Gothic-Regular",
"stdMonoItalic": "VL-Gothic-Regular",
"stdMonoBoldItalic": "VL-Gothic-Regular",
"stdSans": "VL-Gothic-Regular",
"stdSansBold": "VL-Gothic-Regular",
"stdSansItalic": "VL-Gothic-Regular",
"stdSansBoldItalic": "VL-Gothic-Regular"
},
"styles" : [
["base" , {
"wordWrap": "CJK"
}],
["literal" , {
"wordWrap": "None"
}]
]
}
以下のように作成
$ mkdir ~/.rst2pdf $ vi ~/.rst2pdf/config~/.rst2pdf/configに以下のように記述します。
[general] stylesheets="ja" compressed=flase font_path="~/Library/Fonts" header= footer= fit_mode="shrink" break_level=0
後は以下のように叩くだけでPDFファイルが出力されます。
$ rst2pdf -o output.pdf input.rst
完了後は以下のようなフォルダ構成になっているはずです。
参考リンク
~/.rst2pdf/config -project |-input.rst |-ja.json |-ja.style |-output.pdf以上です。お疲れ様でした!
0 件のコメント:
コメントを投稿