How to create a PDF-out-of-Sphinx-documentation-tool
Solution 1
This is from the official Sphinx documentation. If you have pdfTex
tool installed in your machine, all you need is:
$ make latexpdf
Then, the generated pdf file(s) will be under _build/latex/<PROJECT-NAME>.pdf
So, the complete process from scratch would be as follows:
$ pip install -U sphinx # install the package
$ sphinx-quickstart # create a new project (answer the questions)
$ make latexpdf # compile and generate pdf file
Note that you may also "optionally" install whatever extensions needed by editing the file config.py
NOTE: This answer assumes LaTeX engine is installed on your machine.
Solution 2
I have succeeded in generating a PDF file for the DevStack document by following the configuration changes in this link:
Here are the steps:
-
Edit your
conf.py
(edit or append values)extensions = ['rst2pdf.pdfbuilder'] pdf_documents = [('index', u'rst2pdf', u'Sample rst2pdf doc', u'Your Name'),]
-
Install the "
rst2pdf
" if necessarypip install rst2pdf
-
Build the PDF file like this:
sphinx-build -b pdf doc/source doc/build
Solution 3
Succeeded in Pdf Generation via Latex (for windows 10)... No need to change existing conf.py file in Sphinx... the best solution is install MiKTeX....install Perl (ActiveState).... after when running sphinx type 'make HTML' type 'make latex' and then make latexPdf... this solved my issue.
Solution 4
You could avoid rst2pdf and use make pdflatex
to build pdf output via a latex file.
cf more info:
https://docs.typo3.org/typo3cms/extensions/sphinx/AdvancedUsersManual/RenderingPdf/
Solution 5
Make sure to have a look at http://rst2pdf.ralsina.me/handbook.html#sphinx.
Following applies to Ubuntu 16.
But it is probably less painful to install a full LaTex suite than to try to get this tool running; it is very sensitive to errors, and is difficult to use.
I took a look there (https://tex.stackexchange.com/a/95373) and it looks daunting...
this is more encouraging: https://milq.github.io/install-latex-ubuntu-debian/
And I did it:
sudo apt-get install texlive-full
make clean latexpdf
is worthwhile your patience (and disk space) to install. I got rid of rst2pdf.
niceseb
Updated on November 27, 2021Comments
-
niceseb over 2 years
Followed this link to try and generate pdf from Sphinx:
https://www.quora.com/How-to-create-a-PDF-out-of-Sphinx-documentation-tool
$ sphinx-build -b pdf source build/pdf Error: Cannot find source directory `/Users/seb/mydocs/source'. $ make all-pdf make: *** No rule to make target `all-pdf'. Stop. $ make pdf make: *** No rule to make target `pdf'. Stop.
Since tried in OSX:
$ conda install -c dfroger rst2pdf=0.93 Fetching package metadata ......... Solving package specifications: . Error: Package missing in current osx-64 channels: - rst2pdf 0.93*
You can search for packages on anaconda.org with
anaconda search -t conda rst2pdf
EDIT:
After pip install rst2pdf
install rst2pdf register rst2pdf in your conf.py Sphinx config extensions = ['sphinx.ext.autodoc','rst2pdf.pdfbuilder']
But adding 'rst2pdf.pdfbuilder' causes
Extension error: Config value 'math_number_all' already present make: *** [html] Error 1 $ sphinx-build -bpdf sourcedir outdir
But what do I specify as sourcedir and outdir? Example please.
EDIT:
Now after make html
and then:
$ rst2pdf index.rst output.pdf index.rst:14: (ERROR/3) Unknown directive type "toctree". .. toctree:: :maxdepth: 2
introduction tutorial multiple_jobs deployment project
index.rst:26: (ERROR/3) Unknown interpreted text role "ref". index.rst:27: (ERROR/3) Unknown interpreted text role "ref". index.rst:28: (ERROR/3) Unknown interpreted text role "ref".
Also:
$rst2pdf.py index.rst -o mydocument.pdf
Does produce a mydocument.pdf but completely different from html and toc to all the pages are not even there?