Memo about Sphinx Part 2 (PDF output using rst2pdf extension)

How to output the created document as pdf using rst2pdf

environment

OS:Mac OS X 10.9.5 Python:Ver.2.7.7

Install rst2pdf

$ sudo easy_install rst2pdf
・ ・ ・
Finished processing dependencies for rst2pdf

If you get this result, you're done.

Edit configuration file

conf.py Add the following to 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 Add the following to the Makefile

pdf:
	$(SPHINXBUILD) -b pdf $(ALLSPHINXOPTS) $(BUILDDIR)/pdf
	@echo
	@echo "Build finished. The PDF files are in _build/pdf."

ja.json Add 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"
        }]
     ]
 }

Build

$ make pdf

Generated in the _build / pdf folder.

If you get an error

If you get the following error when installing rst2pdf

error: Setup script exited with error: command 'cc' failed with exit status 1

Install xcode-select

$ xcode-select --install

Recommended Posts

Memo about Sphinx Part 2 (PDF output using rst2pdf extension)
PDF output with Latex extension in Sphinx
Memo about Sphinx Part 1 (Creating a project)
Number chapters and sections when PDF output (rst2pdf) with Sphinx