rst2pdfを使って、作成したドキュメントをpdfで出力する方法
環境
OS:Mac OS X 10.9.5
Python:Ver.2.7.7
rst2pdfのインストール
$ sudo easy_install rst2pdf
・・・
Finished processing dependencies for rst2pdf
この結果が出れば完了。
設定ファイルの編集
conf.py
conf.pyに以下を追加
extensions = ['rst2pdf.pdfbuilder']
# -- Options for PDF output --------------------------------------------------
pdf_documents = [
('index', u'MyProject', u'My Project', u'Author Name'),
]
pdf_stylesheets = ['sphinx','kerning','a4','ja']
pdf_language = "ja"
Makefile
Makefileに以下を追加
pdf:
$(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) $(BUILDDIR)/pdf
@echo
@echo "Build finished. The PDF files are in _build/pdf."
ja.json
ja.jsonを追加する
{
"embeddedFonts" : [
"VL-Gothic-Regular.ttf",
"VL-PGothic-Regular.ttf",
"ipam.otf",
"ipag.otf",
"ipagp.otf",
"ipamp.otf"
],
"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"
}]
]
}
ビルド
$ make pdf
_build/pdfフォルダ内に生成される。
エラーが出た場合
rst2pdfのインストール時に以下のようなエラーが出た場合
error: Setup script exited with error: command 'cc' failed with exit status 1
xcode-selectのインストールを行う
$ xcode-select --install