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: Best way to create a large number of documents from database
Date: Thu, 16 Apr 2020 17:39:57 +0100	[thread overview]
Message-ID: <CAL7_PC4NgSbmPcZabnE=KNE-3YnLxqKc424CVZ9F5hjVs0T2NA@mail.gmail.com> (raw)
In-Reply-To: <780bff75-0ea2-f150-5b6e-5aed60085c49@xs4all.nl>


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

A relatively simple way is to use a templating system such as jinja2 and
iterate over a mkiv template.
Calling context with subprocess and you got the result.

Le jeu. 16 avr. 2020 à 15:52, Hans Hagen <j.hagen@xs4all.nl> a écrit :

> On 4/16/2020 4:38 PM, Mojca Miklavec wrote:
> > On Thu, 16 Apr 2020 at 11:29, Taco Hoekwater wrote:
> >>> On 16 Apr 2020, at 11:12, Mojca Miklavec wrote:
> >>>
> >>> I have been asked to create a few thousand PDF documents from a CSV
> >>> "database" today
> >>
> >> In CPU cycles, the fastest way is to do a single context —once
> >> run generating all the pages as a single document, then using
> >> mutool merge to split it into separate documents using a (shell)
> >> loop.
> >
> > Just to make it clear: I don't really need to optimize on the CPU end,
> > as the bottleneck is on the other side of the keyboard, so as long as
> > the CPU can process 5k pages today, I'm fine with it :) :) :)
>
> 5K is nothing ... so that will work
>
> >>> One option is that I quickly draft a python script that creates a few
> >>> thousand TeX documents and compiles them individually, but it might be
> >>> easier if there was a way to just create a single template document
> >>> and then run something like
> >>>     context --some-params --N=42 --output=document-0042.pdf
> template.tex
> >>> or something along those lines.
> >>
> >> If you want to go this route (and you may have to if not each record
> >> fits exactly within a single page),
> >
> > I do have one page per document. The more annoying part is having
> > strange document names that need more attention when mapping page
> > number -> name (I'm not saying this is not doable).
>
> so, don't make files:
>
> - write a tex file foo.tex
> - process it: context --batch --result=1 --once foo
>
> etc ... so, use --result for the target name and use the same input name
>
> (I won't bother you with the template system in context that no one
> knows of.)
>
>   Hans
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
> ___________________________________________________________________________________
> 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
>
> ___________________________________________________________________________________
>

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

[-- Attachment #2: Type: text/plain, Size: 493 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:[~2020-04-16 16:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16  9:12 Mojca Miklavec
2020-04-16  9:29 ` Taco Hoekwater
2020-04-16 14:38   ` Mojca Miklavec
2020-04-16 14:52     ` Hans Hagen
2020-04-16 16:39       ` kaddour kardio [this message]
2020-04-16 17:46       ` template system (was: Best way to create a large number of documents from database) Henning Hraban Ramm
2020-04-16 17:57         ` template system Wolfgang Schuster
2020-04-16 18:23           ` Henning Hraban Ramm
2020-04-16 18:32       ` Best way to create a large number of documents from database Mojca Miklavec
2020-04-16 19:01         ` Pablo Rodriguez
2020-04-16 20:03         ` Hans Hagen
2020-04-17 14:37     ` Mojca Miklavec
2020-04-17 19:11       ` Hans Hagen
2020-04-23  6:48         ` Mojca Miklavec

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_PC4NgSbmPcZabnE=KNE-3YnLxqKc424CVZ9F5hjVs0T2NA@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).