I use DOMPDF to create a PDF document. It works well but the document has 4 pages, all are size of A4.
For example:
Page 1 = Intro
Page 2 = Big table with alot of information
Page 3 = Outro
Page 4 = Logo
For pages 1,3 and 4 the A4 size is good. For page 2 I want to change the page size to A3.
I hope someone can help me out.
Dompdf does not yet support this type of functionality. To achieve something like this you would need to render each segment separately with Dompdf then combine them using an external library such as libmergepdf (or some other method).
This, of course, assumes you can easily break your document into separate HTML files.
Some (pseudo-ish) code:
<?php
use Dompdf\Dompdf;
use iio\libmergepdf\Merger;
use iio\libmergepdf\Pages;
$dompdf = new Dompdf();
$dompdf->loadHtml("a4section.html");
$dompdf->setPaper("a4");
$dompdf->render();
file_put_contents('a4section.pdf', $dompdf->output());
unset($dompdf);
$dompdf = new Dompdf();
$dompdf->loadHtml("a3section.html");
$dompdf->setPaper("a3");
$dompdf->render();
file_put_contents('a3section.pdf', $dompdf->output());
$merger = new Merger;
$merger->addIterator(['a4section.pdf', 'a4section.pdf']);
$createdPdf = $merger->merge();
?>
There's a related enhancement request for this type of functionality using a single HTML document, but no timeline for implementation. See https://github.com/dompdf/dompdf/issues/498