send a pdf union from phpmailer with the fpdi and fpdf libraries

  fpdf, fpdi, php, phpmailer

hello good evening I have a problem when trying to send a pdf union from phpmailer that I use with the FPDI and FPDF library.

$filename = "example.pdf";
$document = $pdf->Output($filename, 'S');
$printpdf = merge($folders,$filename);

This line currently works for me as well as I have it $mail->AddStringAttachment($document, $filename);

but when I try to pass the variable $printpdf where it does the union of the pdfs, I don’t know if I’m passing the parameters wrong
here is the example $mail->AddStringAttachment($printpdf, $filename);

Source: Ask PHP