DOMPDF page orientation for both landscape and portrait

In HTML format 3. Each sheet is a table. We need to convert something to pdf, the last sheet was in the landscape! It works with portraits, and how to make one of the album sheets .... I don’t understand ...

+6
source share
1 answer

dompdf currently cannot do this. If you want to continue using dompdf, you will have to generate different oriented sections separately, and then combine them using an external application.

There are many applications for combining multiple PDFs. I used to use pdftk . This is an executable file, so you will need to install it and run it on your system. For instance:

use Dompdf\Dompdf; $dompdf = new Dompdf(); $dompdf->load_html('...'); $dompdf->render(); file_put_contents($dompdf->output(), 'pdf1.pdf'); unset($dompdf); $dompdf = new DOMPDF(); $dompdf->set_paper('letter', 'landscape'); $dompdf->load_html('...'); $dompdf->render(); file_put_contents($dompdf->output(), 'pdf2.pdf'); exec('pdftk A=pdf1.pdf B=pdf2.pdf cat A1 B2 output combined.pdf'); 

I have not used it, but libmergepdf looks like a decent solution.

 use iio\libmergepdf\Merger; use Dompdf\Dompdf; $m = new Merger(); $dompdf = new Dompdf(); $dompdf->load_html('...'); $dompdf->render(); $m->addRaw($dompdf->output()); unset($dompdf); $dompdf = new DOMPDF(); $dompdf->set_paper('letter', 'landscape'); $dompdf->load_html('...'); $m->addRaw($dompdf->output()); $dompdf->render(); file_put_contents('combined.pdf', $m->merge()); 
+9
source

All Articles