I do a lot of dynamic generation of PDF files as mail attachments, that are never sent to the server as an actual file. I recently had a need to combine them into a single file, which isn’t well documented but is pretty simple – the following function takes an array of Zend_PDF objects and returns them as a single, merged PDF document. Note that some extended functionality (like booksmarks) may be lost.

I’m a big fan of the Zend_PDF class, and generally prefer to use it over other PDF libraries, but sometimes that’s not always possible. You can use other PDF generation tools like TCPDF or DOMPDF to get the raw output, then convert that to a Zend_PDF object with Zend_PDF::parse($output_string);