How to prevent the resizing of pages in PDF?

I create a PDF where I define absolute measurements. However, when I print this PDF, the measurements aren't correct. I want to have a PDF file that contains no differences between the actual size vs

I create a PDF where I define absolute measurements. However, when I print this PDF, the measurements aren't correct. I want to have a PDF file that contains no differences between the actual size vs "fit to page" when printing.

Posted on StackOverflow on Jun 6, 2014 by Cristi B.

Please add the following line to your code. This line will make sure that the page isn't scaled when printed:

writer.addViewerPreference(PdfName.PRINTSCALING, PdfName.NONE);

This is the only parameter you can set to influence the print setting. You can't tell a viewer that it needs to fit the page to the size of the printer page. You can only instruct the viewer that the actual size needs to be taken, by setting the PRINTSCALING to NONE.



Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now