@Jack R rather than recreating the native statement, your script can just output each individual statement as a pdf and then combine them into a single pdf with a simple template that uses
<pdfset>
. Either temporarily store them in the file cabinet, or there is a trick you can use to get the generated xml of a statement which is to render to "HTML" and then repace the