Skip to content

Commit

Permalink
Merge pull request anru#43 from anshulc95/save-button
Browse files Browse the repository at this point in the history
This adds the button to export the document as PDF
  • Loading branch information
anru authored Oct 11, 2018
2 parents 620b8ab + 502fe26 commit 6e8b18a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
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 %}

0 comments on commit 6e8b18a

Please sign in to comment.