jQuery.extend({ UnitUtil: (function() { var pxWidth = 0; var tmpNode = document.createElement("DIV"); tmpNode.style.cssText = "width:1mm;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden"; document.body.appendChild(tmpNode); pxWidth = tmpNode.getBoundingClientRect().width; tmpNode.parentNode.removeChild(tmpNode); return { mm2px: function (mm) { return parseFloat((mm * pxWidth).toFixed(0)); }, px2mm: function (px) { return parseFloat((px / pxWidth).toFixed(0)); } }; })() });