2

I am using the mpdf library for generating the pdf, how can I generate multiple pdf using this library.

              include '../libs/mpdf/vendor/autoload.php';
                      
                      for ($i=1; $i<count($sheetData); $i++) {
                      $name = $sheetData[$i][0];
                      $fName = $sheetData[$i][1];
                      $rollNo = $sheetData[$i][2];
                      $dept = $sheetData[$i][3];
                      $sessionType = $sheetData[$i][4];
                      $semester = $sheetData[$i][5];
                      $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => [290, 236]]);
                      $stylesheet = file_get_contents('../assets/css/style.css');
                      $mpdf->WriteHTML($stylesheet, \Mpdf\HTMLParserMode::HEADER_CSS);
                      ob_end_clean();
                      $mpdf->WriteHTML('<p> My Layout </p>')

                      $filename = time().'.pdf';
                      $mpdf->Output($filename ,'D');
                      unset($mpdf);
                      }

Only one file is generated instead of multiple, How can I generate multiple files.

Hadayat Niazi
  • 1,991
  • 3
  • 16
  • 28
  • What is the current behaviour? You need to provide more details. This code example should work as you expect. – Finwe Feb 28 '21 at 18:14

1 Answers1

-1

Destroy the $mpdf object after you call the output. Simply unset($mpdf);.

Dave
  • 5,108
  • 16
  • 30
  • 40