I need to somehow calculate how many a4 papers will a div on my website contain. I know that a4 paper size in pixels changes based on a screens dpi. I'm looking for a way to calculate the users screen dpi then convert it to a4 page measures in pixels and divide my div's height by that amount in order to simulate the page count using javascript or Jquery. Would that be a good way to do it or is there an alternative? And how can I know a given screens dpi (whatever it may be) and convert it to pixels?
Asked
Active
Viewed 2,135 times
0
-
Take a look at WURFL: http://wurfl.sourceforge.net/help_doc.php#display – Paul Nov 19 '14 at 00:14
1 Answers
0
You can calculate the user's screen DPI using:
<div id='testdiv' style='height: 1in; left: -100%; position: absolute; top: -100%; width: 1in;'></div>
and
dpi_x = document.getElementById('testdiv').offsetWidth;
dpi_y = document.getElementById('testdiv').offsetHeight;
console.log("dpi_x: "+dpi_x+", dpi_y:"+dpi_y);
Additionally, you might want to give this a read.
-
-
-
Thank you that didn't quit solved it but it set me in the right direction – durian Nov 19 '14 at 00:37