Will it be possible to create multiple PDF outputs from a single call to typst?

In the recent blog post on automated generation of PDF there is a description of how a single typst file can take inputs from another source (e.g., an external json file) and be compiled to a single output based on the contents of the json file.

What I would like eventually is to be able to generate multiple output files from a single input file, for instance, rather than passing in a single customer’s details (as in the blog post), perhaps you could pass in the details for many customers and have typst generate a series of output PDFs like account_001.pdf, account_002.pdf, etc. (and maybe even the output file name could be described in the typst file or with command line options somehow).

I currently do this type of task using quarto and R, and I can imagine from the blog post how I could do it using shell scripts, but for various lightweight tasks it would be nice if it could be handled within a single call to the typst compiler itself.

Is this something that others have thought about and/or rejected as a possible future step in automated PDF generation?

2 Likes

See Allow using page number template for PDF to produce multiple PDF files · Issue #7342 · typst/typst · GitHub.

1 Like

I had the very same thought reading the blog post, especially as this is something where typsts incremental compilation can shine, and opened a feature request here:

1 Like

I hadn’t even considered the incremental compilation advantages but that could make it possible to compile (say) 1000 versions of a document in far less than 1000x a single compilation.

I’m assuming it could also be possible to parallelise aspects of the process too if the typst compiler knew that the documents are independent of one another (although possibly then it becomes harder to use the incremental compilation tricks).