Controlling the IE7 “Shrink to Fit” print setting using JavaScript
You may have noticed that printing in Internet Explorer 7 has a new feature – "Shrink to Fit". In some situations, such as when pages are in an iFrame, "Shrink to Fit" is always applied by default. For general web pages this feature may be appreciated, but in a web application where developers want to control the layout of the page, and perhaps generate reports, we do not appreciate IE7′s changing the print layout at all.
If you have not been challenged by this behaviour yet, don't worry – you will! And when you do, here is the solution.
Instead of the typical "print()" command in JavaScript, use:
document.execCommand('print', false, null);
Or if you are wanting to print a document inside an iFrame you can use something like:
window.frames(0).focus();
window.frames(0).document.execCommand('print', false, null);
Note: This solution is for Internet Explorer 7 only – I leave it up to you to do the browser detection.


August 7th, 2010 at 9:00 am
Genius! Thank you very much. Also works in IE 8.
October 20th, 2010 at 3:42 am
Thanks for this – *very* helpful.
Do you know what the third parameter is for?
January 18th, 2011 at 3:02 am
This was a lifesaver, I would have to put all my CSS into tables not to be this script!
Thanks a milion!
September 1st, 2011 at 4:46 am
Very good !! It works for me in IE 9 !! Thank you