dompdf - scale the pdf to fit page

Petros Mastrantonas picture Petros Mastrantonas · Apr 24, 2015 · Viewed 15.3k times · Source

So I am using dompdf to create pdfs of html. Which works really good, the only problem is when the html is too big and dompdf creates it over two pages. Is there a way maybe in dompdf or in html to scale it to one page only?

Help would be greatly appreciated! Thank you!

Here is my config and my code to create pdfs.

define("DOMPDF_ENABLE_HTML5PARSER", true);
define("DOMPDF_ENABLE_FONTSUBSETTING", true);
define("DOMPDF_UNICODE_ENABLED", true);
define("DOMPDF_DPI", 120);
define("DOMPDF_ENABLE_REMOTE", true);

require_once 'dompdf/dompdf_config.inc.php';

$dompdf = new \DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper("a4", "portrait");
$dompdf->render();
$dompdf->stream("page.pdf", array("Attachment" => 0));  

Answer

Halayem Anis picture Halayem Anis · Apr 30, 2015

Sorry, but there is NO setting in DOMPDF to do that.
To achieve your needs, you have to play with CSS files to custom your images size or text font size