DomPDF - Changing the point/pixel ratio

I'm trying to use DomPDF to generate a PDF out of some HTML. I need the page to be 20mm x 20mm, so I use the following:

CPDF_Adapter::$PAPER_SIZES['my_square_page'] = array(0, 0, 566.929134, 566.929134);
$dompdf->set_paper('my_square_page','portrait');

It works properly, if I check the PDF properties the size is ok. The HTML that will appear in the PDF has a container div of 490x490px. This size cannot be changed, as the elements inside that div are absolutely positioned.

The problem, then, is that in the generated PDF the div does not cover the entire page. I've tried setting the DPI, using different values in

def("DOMPDF_DPI", 150);

But it does not seem to make any difference at all. The output I get is this (gray borders are from the PDF reader):

enter image description here

I've tried setting the width and height of body and html in the CSS of the content, but it does not work.

You can check the source code of my sample case here.

Upvotes: 2

Views: 6306

Answers (1)

Ok, I figured it out. Looks like the line

def("DOMPDF_DPI", 150);

does not actually do anything. I did change the dompdf_config.custom.inc file and then it worked. Added this:

define("DOMPDF_DPI", 62.230);

But now the images look too big :S

enter image description here

Upvotes: 2

Related Questions