Skip to content
This repository has been archived by the owner on Oct 21, 2018. It is now read-only.

This adds the button to export the document as PDF #43

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rsted/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
utf8codec = codecs.lookup('utf-8')

from flask import current_app
from flask import request

try:
from cStringIO import StringIO
Expand All @@ -13,6 +14,9 @@ def rst2pdf(content, theme=None):
topdf = RstToPdf(basedir=current_app.config.root_path, breaklevel=0)

buf = StringIO()

content = request.form['text']

if not content:
content = '\0'
content_utf8 = utf8codec.encode(content)[0]
Expand Down
13 changes: 7 additions & 6 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,25 @@
{% block content %}
<div class="b_page_cont">
<div class="b_page_left">
<textarea id="editor" rows="15">{{ rst }}</textarea>
<textarea id="editor" rows="15" name="text" form="save_as_pdf">{{ rst }}</textarea>
</div>
<div class="b_page_right">
<div class="right_nav">
<div class="themes left" id="themes">Theme:
<input id="t_basic" type="radio" value="basic" checked="checked" name="style"/><label for="t_basic">Basic</label>
<input id="t_nature" type="radio" value="nature" name="style"/><label for="t_nature">Nature</label>
</div>
</div>
<div class="right">
<form id="save_as_pdf" method="POST" action="{{ request.script_root }}/srv/rst2pdf/">
<input type="submit" id="as_pdf_rst" name="rst" value="Export to PDF"/>
<input type="hidden" id="as_pdf_theme" name="theme"/>
</form>
</div>
<iframe src="{{ request.script_root }}/srv/rst2html/" id="browse"></iframe>
</div>
</div>

</div>

<form id="save_as_pdf" method="POST" action="{{ request.script_root }}/srv/rst2pdf/">
<input type="hidden" id="as_pdf_rst" name="rst" />
<input type="hidden" id="as_pdf_theme" name="theme"/>
</form>

{% endblock %}