Thursday, May 06, 2010

Sphinx PDF with rst2pdf

I deliberately omit word LaT*X in my post to avoid missing people who add '-LaT*X' in search queries. Yes, it is possible to generate PDF with Sphinx without LaT*X in cross-platform way. Yes, on Windows too. You will need only rst2pdf. Actually integration with Sphinx is well described in rst2pdf manual (text and PDF), but people find it hard to find this information, so I'll quote checklist here:
  1. install rst2pdf
  2. register rst2pdf in your conf.py Sphinx config
    extensions = ['sphinx.ext.autodoc','rst2pdf.pdfbuilder']
  3. run
    sphinx-build -bpdf sourcedir outdir
I hope it was helpful. Actually, check the manual - it has some useful options for conf.py and it's more up-to-date.

    5 comments:

    1. Good post and this mail helped me alot in my college assignement. Thanks you for your information.

      ReplyDelete
    2. I am surprised this tip is still actual, but I am glad it helped.

      ReplyDelete
    3. Excellent...i followed this and when i run the comment I am getting the below warning

      WARNING: "pdf_documents" config value references unknown document contents

      any idea how to fix this

      ReplyDelete
    4. To me it seems that there is something wrong with your configuration. The error is printed by this code -http://code.google.com/p/rst2pdf/source/browse/trunk/rst2pdf/pdfbuilder.py#145 I'd try writing to rst2pdf guys.

      ReplyDelete