Reputation: 211
I am creating HTML to PDF with MPDF. It is working awesome. The issue is that I am unable to create two PDFs at the same page. I want to generate two PDFs and both are to auto download and echo a message after the download. My code:
$mpdf=new \mPDF('c','A4','','' , 0, 0, 0, 0, 0, 0);
$body='Hello One';
$mpdf->WriteHTML($body);
$mpdf->Output('demo.pdf','D');
// Second File
$mpdftwo=new \mPDF('c','A4','','' , 0, 0, 0, 0, 0, 0);
$bodytwo='Hello Two';
$mpdftwo->WriteHTML($bodytwo);
$mpdftwo->Output('demotwo.pdf','D');
echo "Thank you" ;
Upvotes: 2
Views: 870
Reputation: 6725
This is not possible with a single HTTP Request. You can do it either by executing separate async (eg AJAX) subrequests for each of downloaded files, or by eg. making an archive file of the PDF files and sending that archive to the user.
Also se this SO answer to the question on the same topic and this Q&A on why it is not possible to use plain HTTP to achieve what you want, at least not in every browser. To quote:
MIME/multipart is for email messages and/or POST transmission to the HTTP server. It was never intended to be received and parsed on the client side of a HTTP transaction. Some browsers do implement it, some others don't.
Upvotes: 1