-
-
Save hit9/7858003 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Install xhtml2pdf (former "pisa"). | |
http://www.xhtml2pdf.com/ | |
- Install Takao Font (TakaoPGothic.ttf). | |
https://launchpad.net/takao-fonts/ | |
- Modify conf.py as below. | |
- Modify Makefile as below. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Tune the html options ### | |
# While you can use any themes, some themes are not so good for slides. | |
html_theme = 'nature' | |
# You may want to hide the sidebar in the slides. | |
html_theme_options = { | |
"nosidebar": "true", | |
} | |
### Add the below code to conf.py ### | |
import docutils.nodes | |
class nextpage(docutils.nodes.Element): pass | |
def visit_nextpage_html(self, node): | |
self.body.append(self.starttag(node, 'div')) | |
self.body.append('<pdf:nextpage />') | |
def depart_nextpage_html(self, node): | |
self.body.append('</div>') | |
def process_nextpage(app, doctree, docname): | |
for node in doctree.traverse(docutils.nodes.section): | |
if node.parent is doctree and doctree.index(node) == 0: | |
continue | |
node.parent.insert(node.parent.index(node), nextpage()) | |
def init_nextpage(app): | |
if not app.config.slide_mode: | |
return | |
app.add_stylesheet('slide.css') | |
app.add_node(nextpage, html=(visit_nextpage_html, depart_nextpage_html)) | |
app.connect('doctree-resolved', process_nextpage) | |
def setup(app): | |
app.add_config_value('slide_mode', False, True) | |
app.connect('builder-inited', init_nextpage) | |
# app.add_stylesheet('custom.css') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### add the below code to Makefile ### | |
pdf: | |
$(SPHINXBUILD) -b html -D slide_mode=1 $(ALLSPHINXOPTS) $(BUILDDIR)/pdf | |
xhtml2pdf $(BUILDDIR)/pdf/slide.html _build/pdf/slide.pdf | |
@echo | |
@echo "Build finished. The PDF file is at $(BUILDDIR)/pdf/slide.pdf." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@font-face { | |
font-family: "Takao"; | |
src: url(_static/TakaoPGothic.ttf); | |
} | |
@page { | |
size: A4 landscape; | |
margin: 1.0cm; | |
} | |
body { | |
font-size: 24pt; | |
line-height: 120%; | |
} | |
body, | |
div.sphinxsidebar h3, | |
div.sphinxsidebar h4, | |
div.body h1, | |
div.body h2, | |
div.body h3, | |
div.body h4, | |
div.body h5, | |
div.body h6 { | |
font-family: "Takao", sans-serif; | |
} | |
div, p, hr, h1, h2 { | |
margin: 0px; | |
padding: 0px; | |
} | |
h1 { | |
margin-top: 10cm; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment