Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOMPDF - Defining DOMPDF_DPI on a case per case basis?

Tags:

php

pdf

dpi

dompdf

Is there something like:

$dompdf = new DOMPDF();
$dompdf->resolution(200);
$dompdf->load_html($html);
$dompdf->render();

Instead of having to set in the dompdf_config.inc.php, as I have multiple PDF files and they need different DPI.

like image 731
Josh Avatar asked Dec 06 '13 03:12

Josh


2 Answers

If you are using the latest code from github then you can do the following:

php

$dompdf = new DOMPDF;
$dompdf->set_option( 'dpi' , '200' );
$dompdf->load_html($html);
$dompdf->render();

The full option list can be seen in the source.

like image 145
BrianS Avatar answered Sep 19 '22 22:09

BrianS


As of 2017 the Dompdf documentation says to set options (search for setHttpContext for an example) including DPI as follows:

$options = new Dompdf\Options();
$options->setDpi(150);
$dompdf = new Dompdf\Dompdf($options);
like image 7
Interlated Avatar answered Sep 19 '22 22:09

Interlated