pdf - 如何创建 PDF-out-of-Sphinx 文档工具

标签 pdf python-sphinx

按照此链接尝试从 Sphinx 生成 pdf:

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.

自从在 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*

您可以在 anaconda.org 上搜索软件包

anaconda search -t conda rst2pdf

编辑:

pip 安装 rst2pdf 后

install rst2pdf
register rst2pdf in your conf.py Sphinx config
extensions = ['sphinx.ext.autodoc','rst2pdf.pdfbuilder']

但是添加“rst2pdf.pdfbuilder”会导致

Extension error:
Config value 'math_number_all' already present
make: *** [html] Error 1


$ sphinx-build -bpdf sourcedir outdir

但是我应该指定什么作为 sourcedir 和 outdir 呢?请举例。

编辑:

现在制作 html 后

然后:

 $ rst2pdf index.rst output.pdf
 index.rst:14: (ERROR/3) Unknown directive type "toctree".

 .. toctree::

 :maxdepth: 2

简介 教程 多个工作 部署 项目

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".

另外:

$rst2pdf.py index.rst -o mydocument.pdf

是否会生成 mydocument.pdf,但与 html 和 toc 完全不同,甚至所有页面都不存在?

Image of pdf verse HTML same page

最佳答案

这来自official Sphinx documentation 。如果您有pdfTex安装在您机器上的工具,您所需要的只是:

$ make latexpdf

然后,生成的pdf文件将位于_build/latex/<PROJECT-NAME>.pdf

所以,从头开始的完整过程如下:

$ pip install -U sphinx # install the package
$ sphinx-quickstart # create a new project (answer the questions)
$ make latexpdf # compile and generate pdf file

请注意,您还可以通过编辑文件config.py“选择性”安装所需的任何扩展。

注意:此答案假设您的计算机上安装了 LaTeX 引擎。

关于pdf - 如何创建 PDF-out-of-Sphinx 文档工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39534718/

相关文章:

java - 将密码应用于具有java数字签名的PDF文件

ios - 在 PDFKitten 中无法进行特殊字符搜索

java - PDF 到达页面末尾时出现问题

python - 如何生成多个手册页?

python - 您可以在 Sphinx 侧边栏中重命名 "table of contents"吗?

java - 字体在 Java 6 下显示不正确

python - Sphinx LaTeX 标记限制

html - 更改 Sphinx 的目录模板

python-sphinx - 一些用于 sublimetext 的在线工具或自动化插件,用于生成 sphinx RST 表

javascript - 如何在Chrome应用程序中打开base64 PDF?