2 var beforePrint = function() {
3 if ($('body').width() > 0) {
4 // 7.5 inches * 96 DPI; maybe make the width a user pref?
5 var maxwidth = 7.5 * 96;
6 $('body').css('zoom', maxwidth / $('body').width());
9 var afterPrint = function() {
10 $('body').css('zoom', 1);
13 if (window.matchMedia) { // chrome, most importantly; also IE10?
14 window.matchMedia('print').addListener(
16 mq.matches ? beforePrint() : afterPrint();
20 $(window).on('beforeprint', beforePrint);
21 $(window).on('afterprint', afterPrint);
23 // got nothing for firefox
24 // https://bugzilla.mozilla.org/show_bug.cgi?id=774398
25 // but firefox already has "shrink to fit"