Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dompdf - scale the pdf to fit page

Tags:

html

php

pdf

dompdf

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));  
like image 773
Petros Mastrantonas Avatar asked Apr 24 '15 13:04

Petros Mastrantonas


Video Answer


1 Answers

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

like image 161
Halayem Anis Avatar answered Sep 20 '22 07:09

Halayem Anis