I am generating multiple PDFs in a loop using mPDF
. Following are the lines of my code:
for($i=0;$i<=3;$i++)
{
$mpdf = new mPDF();
$stylesheet = file_get_contents('style.css');
$mpdf->WriteHTML($stylesheet,1);
$mpdf->WriteHTML('My html');
$mpdf->SetDisplayMode('fullpage');
$pdfname="Invoice_No.$i".".pdf";
$mpdf->Output($pdfname, "I");
}
When the change the parameter I
to F
multiple PDFs are generated on the server. However when using I
as the parameter only first PDF is generated. Is there any way that I can generate multiple PDFs in such a way that I do not have to save them in the server?
Note: Even using parameter D
does not help either
TL;DR No, in one request, there is not.
I
and D
output modes generate the file, send the output from the server to the browser (inline and with forced download respectively) and end execution - so that no further data are sent that would corrupt sent PDF file.
You would have to execute multiple HTTP requests for each file.
Alternatively, you could save PDFs in-memory, later pack them eg to a ZIP file and send the ZIP file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.