On 16 Apr 2020, at 11:12, Mojca Miklavec
wrote: Hi,
I have been asked to create a few thousand PDF documents from a CSV "database" today (which I can easily transform into any other form, like XML or a lua table or TeX definitions or whatever).
Generating a few thousand pages would be straightforward, but I'm sure there are some clever ways to handle this scenario as well, I'm just not aware of them :)
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. Starting up mutool is much faster than starting context, even with lmtx.
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), browse back a day or so in the mailing list archive for Gerben’s question about “Using command line values in a TeX document; writing a script?" The replies offer various options using either lua or tex code to get at user-supplied arguments from the commandline. Best wishes, Taco