Attach a print section multiple times to an email context

Let me start by explaining what I have working now.
I have an email context and I have several print sections: lets start with Invoice and Duplicate Stamp.
My xml has basically this structure:

<invoices>
  <invoice>
    <invoicenumber>I123456</invoicenumber> 
    <originalpath/>
    <invoicelines>
      <invoiceline>
        <product>book 1</product>
      </invoiceline>
      <invoiceline>
        <product>book 1</product>
      </invoiceline>
    </invoicelines>
  </invoice>
</invoices>

The Invoice section is enabled by a control script and the Duplicate Stamp section is disabled by another control script. This combination sends a simple email with an invoice attached as pdf.
However, when the invoice has been generated before and we now want to send a duplicate, workflow makes sure that the originalpath node contains an url to the original invoice. In that case a control script disables the Invoice section and and enables the Duplicate Stamp section. This section doesn’t generate an invoice, it only generates a stamp. This control script places the original invoice in the background.

var sectionName = 'Duplicate Stamp';
var section = merge.template.contexts.PRINT.sections[sectionName];
if (!section) throw "'" + sectionName + "' not found";
section.enabled = (isBilling && isDuplicate);
if (section.enabled) {
	section.background.source = BackgroundResource.RESOURCE_IMAGE;
	section.background.allPages = true;
	section.background.url = originalPath;
}

This works perfectly fine.

A second setup we have in place (actually in the same template, but using a different datamapper) is reminders. The xml now looks like this:

<reminders>
  <reminder>
    <remindernumber>R234567</invoicenumber> 
    <reminderlines>
      <reminderline>
        <invoicenumber>I123456</invoicenumber>
        <originalpath>path to original invoice I123456</originalpath>
      </reminderline>
      <reminderline>
        <invoicenumber>I654321</invoicenumber>
        <originalpath>path to original invoice I654321</originalpath>
      </reminderline>
    </reminderlines>
  </reminder>
</reminders>

In this case both the Invoice section and the Duplicate Stamp section are disabled and a third section is enabled: Reminders. This combination sends a simple email (obviously with another text than in the case of an invoice) with a reminder pdf attached. This reminder pdf basically lists all overdue invoices. The originalpath nod is simply ignored.

This also works perfectly fine.

And now comes the hard part. What I now want to do is not only add the reminder section as a pdf, but also a copy of each invoice with the stamp on it.
I am aware of Dynamically add multiple attachments article, but following that article would simply attach a copy of each invoice without putting the stamp on it.

Is there a way to attach the stamped invoices directly, without having workflow first generate each duplicate and have the template attach these pregenerated stamped duplicates?

Thanks for any suggestion.

Hello @Roebie , welcome to our online community!

As for the question asked; is it not just better to create the PDF output for the email attachment separately from creating the email content and use the Dynamic attachments: creating file names based on data fields approach for adding the email attachment in all three cases?