Fix pdf export , make it python3 compatible, Fix markmin2latex import

This commit is contained in:
jvanbraekel
2018-08-02 11:04:14 +02:00
parent 0d8dc294e9
commit 68284be7b0
3 changed files with 9 additions and 10 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ filename = '%s/%s.html' % (request.controller,request.function)
if os.path.exists(os.path.join(request.folder,'views',filename)):
html=response.render(filename)
else:
html=BODY(BEAUTIFY(response._vars)).xml()
html=BODY(BEAUTIFY(response._vars))
pass
=pdf_from_html(html)
}}
+2 -2
View File
@@ -25,7 +25,7 @@ def wrapper(f):
def latex_from_html(html):
markmin = TAG(html).element('body').flatten(markmin_serializer)
return XML(markmin2latex(markmin))
return markmin2latex(markmin)
def pdflatex_from_html(html):
@@ -39,7 +39,7 @@ def pdflatex_from_html(html):
H1('warnings'),
UL(*warnings))).xml())
else:
return XML(out)
return out
def pyfpdf_from_html(html):
+6 -7
View File
@@ -58,7 +58,7 @@ def latex2pdf(latex, pdflatex='pdflatex', passes=3):
# setup the envoriment
tmpdir = mkdtemp()
texfile = open(tmpdir + '/test.tex', 'wb')
texfile = open(tmpdir + '/test.tex', 'wt',encoding="utf-8")
texfile.write(latex)
texfile.seek(0)
texfile.close()
@@ -90,15 +90,14 @@ def latex2pdf(latex, pdflatex='pdflatex', passes=3):
os.unlink(logname)
pdffile = texfile.rsplit('.', 1)[0] + '.pdf'
data = None
if os.path.isfile(pdffile):
fpdf = open(pdffile, 'rb')
try:
with open(pdffile,'rb') as fpdf :
data = fpdf.read()
finally:
fpdf.close()
else:
data = None
removeall(tmpdir)
return data, warnings, errors