I have to generate PDF document from big HTML code (created 1000 or more pages). But standard method limited me - memory. Standard method:

```
$html = generatePDF($data_to_pdf);
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper('a4', 'landscape');
$dompdf->render();
$pdf = $dompdf->output();

file_put_contents('pdf/' . $tmp_name . '.pdf', $pdf);

```

The memory is too small so I need to save the data in part. How to generate PDF page by page? Or something like that? How to fix memory problem?