Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set PDF to print with no scaling

Tags:

printing

pdf

fpdf

I am generating a PDF (using fpdf) and I am wondering if there is a way to set the document's properties to to default to print with no scaling.

So when you select print from the print dialogue menu, scaling is set to none. I'm trying to determine if this is a user setting or something I can control in the creation of the PDF.

Thanks in advance.

like image 289
JCam Avatar asked Jan 18 '11 15:01

JCam


2 Answers

I've done it adding to the method _putcatalog() the following:

$this->_out('/ViewerPreferences [/PrintScaling/None]');

After the line:

$this->_out('/Type /Catalog');

Implementing a method is just fast and easy...

like image 103
onosenday Avatar answered Sep 24 '22 01:09

onosenday


Print-scaling can be turned off for invividual PDF files using Adobe Acrobat, by going to File -> Preferences -> Advanced -> Page scaling. (You can try this using the trial version of Acrobat.)

As for achieving this in code, I've tried and failed to make it work, but the critical difference in the files seems to be:

10 0 obj
<</Metadata 2 0 R/Outlines 6 0 R/Pages 7 0 R/Type/Catalog/ViewerPreferences<</PrintScaling/None>>>>
endobj

for non-scaling PDFs, compared to

10 0 obj
<</Metadata 2 0 R/Outlines 6 0 R/Pages 7 0 R/Type/Catalog>>
endobj

for those that use the default shrink-to-fit option.

like image 39
Richard C Avatar answered Sep 26 '22 01:09

Richard C