GET DPI
Get DPI from javascript
by Alan Dong
HTML
<svg height="100" width="100">
<line x1="0" y1="0" x2="96" y2="0" style="stroke:rgb(255,0,0);stroke-width:2" />
</svg>
JavaScript
//
// inspired by https://stackoverflow.com/a/838755/521197
//
function getDPI() {
var div = document.createElement( "div");
div.style.height = "1in";
div.style.width = "1in";
div.style.top = "-100%";
div.style.left = "-100%";
div.style.position = "absolute";
document.body.appendChild(div);
var result = div.offsetHeight;
document.body.removeChild( div );
return result;
}
/* alert( " DPI: " + getDPI()); */