def courrier_mkiv(request, pk2, pk1):
entry = Courrier.objects.get(pk=pk2)
cource = Patient.objects.get(pk=pk1)
context = dict({'courrier': entry, 'patient': cource})
# buffer = BytesIO()
template = get_template('courrier/courrier.mkiv')
rendered_tpl = template.render(context, request).encode('utf-8')
with tempfile.TemporaryDirectory() as tempdir:
# mtxrun --path=/data/foo --script context
process = Popen(['mtxrun', '--path', tempdir,
'--script=context'
'--result'],
stdin=PIPE,
stdout=PIPE,
)
process.communicate(rendered_tpl)
with open(os.path.join(tempdir, 'textput.pdf'), 'rb') as f:
pdf = f.read()
r = HttpResponse(content_type='application/pdf')
r.write(pdf)
return r
i tried this without success :(
the only workaround u've found for now is to render a tex file and copile it manually.