How to set custom width and height of pdf using dompdf?

Saurabh Gupta picture Saurabh Gupta · Aug 19, 2014 · Viewed 44.6k times · Source

When I create my pdf using dompdf it generates it as default width and height. I want to set custom width and height of my created pdf. If it is not possible in dompdf then kindly suggest some other plugin for php.

Answer

Jorge Caballero picture Jorge Caballero · Aug 19, 2014

By default it's going to render on 'US Letter', you can change this by using:

$dompdf->set_paper(DEFAULT_PDF_PAPER_SIZE, 'portrait');

You can use 'letter', 'legal', 'A4', etc..

Nevertheless you can set your own size like this:

$customPaper = array(0,0,360,360);
$dompdf->set_paper($customPaper);

More info: https://github.com/dompdf/dompdf/wiki/Usage