Good day !
I use mpdf in a loop
require_once __DIR__ . '/vendor/autoload.php';
$path_html= __DIR__.'/html/';
$path_pdf= __DIR__.'/pdf/';
$amount_file=10;
$mpdf = new \Mpdf\Mpdf();
if (!file_exists($path_pdf)) {mkdir($path_pdf, 0755, true);}
function random_html($dir = 'html')
{
$files = glob($dir . '/*.*');
$file = array_rand($files);
return $files[$file];
}
$alphanum = 'abxzrmhtuiops123456789';
for ($amount_file_count=1; $amount_file_count <= $amount_file; $amount_file_count++) {
$rand_file_name = substr(str_shuffle($alphanum), 2, 10) ;
$html_file = file_get_contents(random_html());
$mpdf->WriteHTML($html_file);
$mpdf->Output($path_pdf . $rand_file_name . '.pdf');
echo $amount_file;
}
When create next pdf add old null page, Why? How do this correct? How correct FOR cicle ?