Q:

How to merge multiple pdfs into one without writing the response into a new file

I have been going though examples of merging multiple pdfs into one after fetching them with a curl response.
But, all the examples requires the pdf response to be written into a pdf file and then pass them to fdpi or some other lib to merge them.
I want to skip the file writing operation and want to pass the curl response directly to the fdpi library.
What can be the solution to this?

A:

FPDI depends on filesystem functions such as fseek() or fread() and requires to use a stream wrapper as described here, if you want to import a PDF from a variable.
$pdf = new FPDI();
$pageCount = $pdf->setSourceFile(VarStream::createReference($yourCurlResponse));

