ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: kaddour kardio <kaddourkardio@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Django: using ConTeXT mkiv to output PDF
Date: Fri, 26 Jan 2018 19:41:19 +0100	[thread overview]
Message-ID: <CAL7_PC7nT0zXsZpkntnvmrtxQSDbQmePGWOb8PGm7xXsfZDF4A@mail.gmail.com> (raw)
In-Reply-To: <58c31e44-76d0-9d89-1f1c-36c957d02cfe@wxs.nl>


[-- Attachment #1.1: Type: text/plain, Size: 1035 bytes --]

>
> 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.

[-- Attachment #1.2: Type: text/html, Size: 2652 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2018-01-26 18:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 14:15 kaddour kardio
2018-01-25 10:47 ` Henning Hraban Ramm
2018-01-25 13:58   ` kaddour kardio
2018-01-25 14:19     ` Hans Hagen
2018-01-26 18:41       ` kaddour kardio [this message]
2018-01-27 10:18         ` Hans Hagen
2018-01-28 17:59         ` Pablo Rodriguez
2018-01-28 23:33           ` kaddour kardio
2018-02-02 12:22             ` kaddour kardio
2018-02-02 12:49               ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL7_PC7nT0zXsZpkntnvmrtxQSDbQmePGWOb8PGm7xXsfZDF4A@mail.gmail.com \
    --to=kaddourkardio@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).