This is an archived forum post. The information may be outdated. Contact us if you have any questions.

PDF pixels per inch

parkerm34 wrote on 2019-06-12:
Hi!
Great product, using it for a client project. We have pretty strict sizing requirements and am trying to get to the bottom of what the pixels per inch are.
I found an old forum post saying there are 72 pixels per inch in the PDF but 96 pixels on the browser per inch. I found a more recent post only saying 96 pixels per inch.

To get things to print and download as PDF correctly, what value should I use as pixels per inch?

Thank you!
support wrote on 2019-06-13:
Hi,

Simply we can say the browser uses 96 PPI and we internally use 72 PPI.

72 PPI in PDF means that e.g. A4 paper dimension is 595x842 pixels. So if the conversion to PDF is done, this example CSS rule is applied for A4 paper:
@media (width: 595px) {  body { background-color: coral; } }


Moreover we use smart scaling algorithm to fit more content to the page, so some HTML elements can change their dimensions. You can disable this algorithm by setSmartScalingMode('disabled').

I'd recommend you to try another modes of setSmartScalingMode and setRenderingMode.

E.g. you can get the same PDF as in a browser's window with a specific width. Example code in PHP using the browser's width equal to 1200 px.
$client->setRenderingMode('viewport');
$client->setViewport(1200, 1000);
$client->setSmartScalingMode('viewport-fit');
$client->setNoMargins(true);


Notes:
1. we speak about DPI instead of PPI sometimes as we consider PDF as a printable format
2. there are some useful topics for reading:
-- http://www.judyofthewoods.net/money/pixels_resolution_dpi.html
-- https://graphicdesign.stackexchange.com/questions/199/point-vs-pixel-what-is-the-difference#answer-12644