Commit 990d61e5 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Add the base64 string conversion in view/tex2pdf.html.

parent d5499bc4
......@@ -4,6 +4,7 @@
# Converte to transform a tex file generate by a view as a pdf file
#
#--------------------------------------------------------------------------
import base64
import cStringIO
import os
......@@ -43,21 +44,23 @@
call(cmd, stdout=TemporaryFile())
#
# copy the pdf in the new response
# copy the pdf into a base64 string
#
response.headers['Content-Type']='application/pdf'
fn_pdf = '%s.pdf' % fn
if os.path.exists(fn_pdf):
fi = open(fn_pdf, 'rb')
response.write(fi.read(), escape=False)
data = fi.read()
fi.close()
else:
response.write("\nThe generation of the PDF file failed.", escape=False)
response.write("\nPlease, check the LaTeX file.", escape=False)
data = "\nThe generation of the PDF file failed."
data += "\nPlease, check the LaTeX file."
pass
s64 = base64.b64encode(data)
#
# clean files
# cleaning
#
for ext in ('aux', 'log', 'out', 'pdf', 'tex'):
f = '%s.%s' % (fn, ext)
......@@ -66,8 +69,11 @@
pass
pass
os.chdir(cwd)
#
# go back to the web2py main directory
# Prepare the response
#
os.chdir(cwd)
response.headers['Content-Type']='application/pdf'
response.write(s64, escape=False)
}}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment