Forum How do I...?

scaling PDF page for different PPI?

mchahn
I have software that generates pages assuming 139 PPI (page size of 1068 by 1386). Don't ask why and the code is too large to modify all the sizing which is hard-wired in pixels.

How do I scale the PDF output to match this number of pixels per inch? Simply zooming the contents, as you can do in other renderers, would be great.
mikeday
Currently Prince is hardwired to use 96dpi for CSS pixel units, but we may be able to add an option to override this. We will investigate.
mikeday
Yes, there will be an experimental option available in Prince 9 to change the default DPI value.
justin.barkhuff
Really looking forward to this feature. We're running software that generates pages with hardcoded pixel widths/heights assuming 72 pixels per inch, so Prince's hardcoded 96dpi results in PDFs that are smaller than we need them to be.

Any idea when it will be available?
mikeday
Most of the Prince 9 packages are available for download now, and we will make the release announcement next week. So you can try it out immediately. The experimental option works like this:
$ prince --css-dpi=72 input.html -o output.pdf
justin.barkhuff
Awesome. Appears to be working perfectly. Thank you.
zambadu
That sounds like the option I ever wanted. How can I use it with the PHP-Module?
zambadu
It was so easy that I've found a solution by myself :)
Just add the option to the functions in prince.php (here the one I needed):
 public function convert_string_to_file($dpi, $xmlString, $pdfPath, &$msgs = array())
    {
	$pathAndArgs = $this->getCommandLine();
	$pathAndArgs .= '--css-dpi='.$dpi.' - -o "' . $pdfPath . '"';
	    
        return $this->convert_internal_string_to_file($pathAndArgs, $xmlString, $msgs);
    }



Var dpi makes it able to pass through any DPI-value you need (preview PDFs, etc. ).

Works really fine for me.

Edited by zambadu

daneren2005
Is there still a way to accomplish this same thing? We have a customer that is trying to print with a printer that is reading the 72 DPI and printing at that resolution even though the photos are higher resolution in the PDF itself. Is there a way to override the listed resolution of the PDF?
daneren2005
Ignore my comment. It looks like it is working, but not doing what I thought it would be doing.